X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fstrutil.c;h=050f37bf7090532cc67282e07c10ce2867a985b6;hb=91219afc75c9aa1d0c5e2da5c03343c1e43eb6df;hp=0306ea7c91f940002861e2ce114654e6a82b0b39;hpb=c368e6f3d248a73d69cd0c2c4a7c88a92def55e3;p=libsigrok.git diff --git a/src/strutil.c b/src/strutil.c index 0306ea7c..050f37bf 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -230,7 +230,7 @@ SR_PRIV int sr_atof_ascii(const char *str, float *ret) * @param unit The unit to append to the string, or NULL if the string * has no units. * - * @return A g_try_malloc()ed string representation of the samplerate value, + * @return A newly allocated string representation of the samplerate value, * or NULL upon errors. The caller is responsible to g_free() the * memory. * @@ -272,7 +272,7 @@ SR_API char *sr_si_string_u64(uint64_t x, const char *unit) * * @param samplerate The samplerate in Hz. * - * @return A g_try_malloc()ed string representation of the samplerate value, + * @return A newly allocated string representation of the samplerate value, * or NULL upon errors. The caller is responsible to g_free() the * memory. * @@ -291,7 +291,7 @@ SR_API char *sr_samplerate_string(uint64_t samplerate) * * @param frequency The frequency in Hz. * - * @return A g_try_malloc()ed string representation of the frequency value, + * @return A newly allocated string representation of the frequency value, * or NULL upon errors. The caller is responsible to g_free() the * memory. * @@ -303,10 +303,7 @@ SR_API char *sr_period_string(uint64_t frequency) int r; /* Allocate enough for a uint64_t as string + " ms". */ - if (!(o = g_try_malloc0(30 + 1))) { - sr_err("%s: o malloc failed", __func__); - return NULL; - } + o = g_malloc0(30 + 1); if (frequency >= SR_GHZ(1)) r = snprintf(o, 30, "%" PRIu64 " ns", frequency / 1000000000); @@ -336,7 +333,7 @@ SR_API char *sr_period_string(uint64_t frequency) * @param v_p The voltage numerator. * @param v_q The voltage denominator. * - * @return A g_try_malloc()ed string representation of the voltage value, + * @return A newly allocated string representation of the voltage value, * or NULL upon errors. The caller is responsible to g_free() the * memory. * @@ -347,10 +344,7 @@ SR_API char *sr_voltage_string(uint64_t v_p, uint64_t v_q) int r; char *o; - if (!(o = g_try_malloc0(30 + 1))) { - sr_err("%s: o malloc failed", __func__); - return NULL; - } + o = g_malloc0(30 + 1); if (v_q == 1000) r = snprintf(o, 30, "%" PRIu64 "mV", v_p);