fix: Have not free the char buffer formatting from base lib

This commit is contained in:
dreamsource-tai 2024-07-25 11:29:22 +08:00
parent c50e8f714a
commit a716beeef8
3 changed files with 16 additions and 6 deletions

View File

@ -260,8 +260,7 @@ void DeviceOptions::bind_samplerate(const QString &name, const QString label,
QString DeviceOptions::print_samplerate(GVariant *const gvar)
{
char *const s = sr_samplerate_string(
g_variant_get_uint64(gvar));
char *const s = sr_samplerate_string(g_variant_get_uint64(gvar));
const QString qstring(s);
g_free(s);
return qstring;
@ -293,14 +292,20 @@ QString DeviceOptions::print_timebase(GVariant *const gvar)
{
uint64_t p, q;
g_variant_get(gvar, "(tt)", &p, &q);
return QString(sr_period_string(p * q));
char *pstr = sr_period_string(p * q);
QString qstr(pstr);
g_free(pstr);
return qstr;
}
QString DeviceOptions::print_vdiv(GVariant *const gvar)
{
uint64_t p, q;
g_variant_get(gvar, "(tt)", &p, &q);
return QString(sr_voltage_string(p, q));
char *pstr = sr_voltage_string(p, q);
QString qstr(pstr);
g_free(pstr);
return qstr;
}
void DeviceOptions::bind_bandwidths(const QString &name, const QString label, int key,

View File

@ -222,7 +222,11 @@ QString ProbeOptions::print_vdiv(GVariant *const gvar)
q = 1;
p /= 1000;
}
return QString(sr_voltage_string(p, q));
char *pstr = sr_voltage_string(p, q);
QString qstr(pstr);
g_free(pstr);
return qstr;
}
QString ProbeOptions::print_coupling(GVariant *const gvar)

View File

@ -618,8 +618,9 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str)
}
s = sr_samplerate_string(_session->cur_snap_samplerate());
sprintf(meta, "samplerate = %s\n", s); str += meta;
g_free(s);
s = NULL;
uint64_t tmp_u64;
int tmp_u8;