guid_to_string should be freed.

This commit is contained in:
Christopher Lam 2023-09-19 20:25:30 +08:00
parent c05b59560b
commit 8e21d3328f
4 changed files with 16 additions and 4 deletions

View File

@ -1226,9 +1226,10 @@ inline SCM return_scm_value(ValueType value)
if (guid_list.empty()) if (guid_list.empty())
return scm_simple_format(SCM_BOOL_F, list_format_str, scm_list_1(no_value)); return scm_simple_format(SCM_BOOL_F, list_format_str, scm_list_1(no_value));
SCM string_list{SCM_EOL}; SCM string_list{SCM_EOL};
char guid_str[GUID_ENCODING_LENGTH+1];
for(auto guid : guid_list) for(auto guid : guid_list)
{ {
auto guid_str{guid_to_string(&guid)}; guid_to_string_buff (&guid, guid_str);
auto guid_scm{scm_from_utf8_string(guid_str)}; auto guid_scm{scm_from_utf8_string(guid_str)};
string_list = scm_cons(guid_scm, string_list); string_list = scm_cons(guid_scm, string_list);
} }

View File

@ -225,7 +225,11 @@ GncSqlColumnTableEntryImpl<CT_OWNERREF>::add_to_query(QofIdTypeConst obj_name,
buf.str(""); buf.str("");
auto guid = qof_instance_get_guid(inst); auto guid = qof_instance_get_guid(inst);
if (guid != nullptr) if (guid != nullptr)
buf << guid_to_string(guid); {
char strbuff[GUID_ENCODING_LENGTH+1];
guid_to_string_buff (guid, strbuff);
buf << strbuff;
}
else else
buf << "NULL"; buf << "NULL";
vec.emplace_back(std::make_pair(guid_hdr, quote_string(buf.str()))); vec.emplace_back(std::make_pair(guid_hdr, quote_string(buf.str())));

View File

@ -877,7 +877,12 @@ std::string
GncOptionAccountSelValue::serialize() const noexcept GncOptionAccountSelValue::serialize() const noexcept
{ {
static const std::string no_value{"No Value"}; static const std::string no_value{"No Value"};
return guid_equal(guid_null(), &m_value) ? no_value : guid_to_string(&m_value); if (guid_equal(guid_null(), &m_value))
return no_value;
gchar strbuff[GUID_ENCODING_LENGTH + 1];
guid_to_string_buff (&m_value, strbuff);
return strbuff;
} }
bool bool

View File

@ -898,7 +898,9 @@ operator<< <GncOptionAccountListValue>(std::ostream& oss,
first = false; first = false;
else else
oss << " "; oss << " ";
oss << guid_to_string(&value); char strbuff[GUID_ENCODING_LENGTH+1];
guid_to_string_buff (&value, strbuff);
oss << strbuff;
} }
return oss; return oss;
} }