Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
David Youssefi
otb
Commits
fadb863e
Commit
fadb863e
authored
Jul 15, 2020
by
Julien Osman
Browse files
BUG: Avoid a memory leak and avoid returning const strings
parent
31ab00f5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
9 deletions
+11
-9
Modules/Core/Metadata/include/otbMetadataSupplierInterface.h
Modules/Core/Metadata/include/otbMetadataSupplierInterface.h
+1
-1
Modules/Core/Metadata/include/otbXMLMetadataSupplier.h
Modules/Core/Metadata/include/otbXMLMetadataSupplier.h
+2
-2
Modules/Core/Metadata/src/otbXMLMetadataSupplier.cxx
Modules/Core/Metadata/src/otbXMLMetadataSupplier.cxx
+6
-4
Modules/IO/IOGDAL/include/otbGDALImageIO.h
Modules/IO/IOGDAL/include/otbGDALImageIO.h
+1
-1
Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
+1
-1
No files found.
Modules/Core/Metadata/include/otbMetadataSupplierInterface.h
View file @
fadb863e
...
...
@@ -77,7 +77,7 @@ public:
* depends on the specific implementation. Returns empty string when path is not found,
* and hasValue is set to False.
* If band >= 0, the metadata value is looked in the specified band*/
virtual
const
std
::
string
GetMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
,
int
band
=-
1
)
const
=
0
;
virtual
std
::
string
GetMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
,
int
band
=-
1
)
const
=
0
;
bool
HasValue
(
std
::
string
path
,
int
band
=-
1
);
...
...
Modules/Core/Metadata/include/otbXMLMetadataSupplier.h
View file @
fadb863e
...
...
@@ -52,7 +52,7 @@ public:
* @param band not used
* @return The value corresponding to path. Empty string if not found.
*/
const
std
::
string
GetMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
,
int
band
=
1
)
const
override
;
std
::
string
GetMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
,
int
band
=
1
)
const
override
;
/**
* @brief Get the first metadata value corresponding to a given path
...
...
@@ -61,7 +61,7 @@ public:
* @param hasValue True if path is found
* @return The value corresponding to path. Empty string if not found.
*/
const
std
::
string
GetFirstMetadataValue
(
const
std
::
string
paths
,
bool
&
hasValue
)
const
;
std
::
string
GetFirstMetadataValue
(
const
std
::
string
paths
,
bool
&
hasValue
)
const
;
/**
* @brief Get the metadata value corresponding to a given path
...
...
Modules/Core/Metadata/src/otbXMLMetadataSupplier.cxx
View file @
fadb863e
...
...
@@ -36,7 +36,7 @@ XMLMetadataSupplier::XMLMetadataSupplier(const std::string & fileName)
CPLDestroyXMLNode
(
psNode
);
}
const
std
::
string
XMLMetadataSupplier
::
GetMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
,
int
band
)
const
std
::
string
XMLMetadataSupplier
::
GetMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
,
int
band
)
const
{
const
char
*
ret
=
CSLFetchNameValue
(
m_MetadataDic
,
path
.
c_str
());
if
(
ret
)
...
...
@@ -49,7 +49,7 @@ const std::string XMLMetadataSupplier::GetMetadataValue(const std::string path,
return
std
::
string
(
ret
);
}
const
std
::
string
XMLMetadataSupplier
::
GetFirstMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
)
const
std
::
string
XMLMetadataSupplier
::
GetFirstMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
)
const
{
// Search for the first joker
std
::
size_t
found
=
path
.
find
(
"_#"
);
...
...
@@ -74,9 +74,11 @@ const std::string XMLMetadataSupplier::GetFirstMetadataValue(const std::string p
if
((
values
!=
nullptr
)
&&
(
values
[
0
]
!=
nullptr
))
{
hasValue
=
true
;
std
::
string
ret
=
std
::
string
(
values
[
0
]);
std
::
string
ret
=
values
[
0
];
ret
=
ret
.
substr
(
ret
.
find
(
'='
)
+
1
);
CSLDestroy
(
values
);
// Return the value part
return
ret
.
substr
(
ret
.
find
(
'='
)
+
1
)
;
return
ret
;
}
else
{
...
...
Modules/IO/IOGDAL/include/otbGDALImageIO.h
View file @
fadb863e
...
...
@@ -210,7 +210,7 @@ public:
std
::
vector
<
std
::
string
>
GetResourceFiles
()
const
override
;
/** Get metadata item in GDALDataset, domain can specified as "domain/key" */
const
std
::
string
GetMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
,
int
band
=
-
1
)
const
override
;
std
::
string
GetMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
,
int
band
=
-
1
)
const
override
;
/** Set metadata item in GDALDataset, domain can specified as prefix of the
* path, like "domain/key"*/
...
...
Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
View file @
fadb863e
...
...
@@ -1835,7 +1835,7 @@ std::vector<std::string> GDALImageIO::GetResourceFiles() const
return
result
;
}
const
std
::
string
GDALImageIO
::
GetMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
,
int
band
)
const
std
::
string
GDALImageIO
::
GetMetadataValue
(
const
std
::
string
path
,
bool
&
hasValue
,
int
band
)
const
{
// detect namespace if any
std
::
string
domain
(
""
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment