mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Add a function to free the memory allocated when calling GetStringFlag
PiperOrigin-RevId: 731778685
This commit is contained in:
committed by
Copybara-Service
parent
20462fafd9
commit
e2b1f47bc5
+3
-1
@@ -103,7 +103,9 @@ class FlagReaderWrapper : public nearby::flags::FlagReader {
|
||||
};
|
||||
NC_DATA flag_value = phenotype_flag_reader_.get_string_flag_value(
|
||||
context_, &flag_name, &default_value);
|
||||
return std::string(flag_value.data, flag_value.size);
|
||||
std::string ret = std::string(flag_value.data, flag_value.size);
|
||||
phenotype_flag_reader_.free_string_value(&flag_value);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -337,6 +337,8 @@ typedef struct NC_PHENOTYPE_FLAG_READER {
|
||||
const NC_DATA (*get_string_flag_value)(READER_CONTEXT context,
|
||||
const NC_DATA* flag_name,
|
||||
const NC_DATA* default_value);
|
||||
// Frees a string allocated when calling get_string_flag_value.
|
||||
const void (*free_string_value)(const NC_DATA* value);
|
||||
} NC_PHENOTYPE_FLAG_READER;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user