X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fanalog.c;h=f26f7a5c2b931e0afa855cd0b106fa401ca7c3cf;hb=2c24077466a299ead689c90f01f55f6d86c7386b;hp=e4521689a11d5ca1338087e1667480aab424c000;hpb=22fb1bffc33b47f575c4b1c967b5051ddb505c5c;p=libsigrok.git diff --git a/src/analog.c b/src/analog.c index e4521689..f26f7a5c 100644 --- a/src/analog.c +++ b/src/analog.c @@ -45,7 +45,7 @@ struct unit_mq_string { uint64_t value; - char *str; + const char *str; }; /* Please use the same order as in enum sr_unit (libsigrok.h). */ @@ -220,44 +220,6 @@ SR_API int sr_analog_to_float(const struct sr_datafeed_analog *analog, return SR_OK; } -/** - * Convert a floating point value to a string, limited to the given - * number of decimal digits. - * - * @param[in] value The value to convert. - * @param[in] digits Number of digits after the decimal point to print. - * Must be >= 0. - * @param[out] result Pointer to store result. Must not be NULL. - * - * The string is allocated by the function and must be freed by the caller - * after use by calling g_free(). - * - * @retval SR_OK Success. - * @retval SR_ERR_ARG Invalid argument. - * - * @since 0.4.0 - */ -SR_API int sr_analog_float_to_string(float value, unsigned int digits, char **result) -{ - unsigned int cnt, i; - - if (!result) - return SR_ERR_ARG; - - /* This produces at least one too many digits. */ - *result = g_strdup_printf("%.*f", digits, value); - for (i = 0, cnt = 0; (*result)[i]; i++) { - if (isdigit((*result)[i++])) - cnt++; - if (cnt == digits) { - (*result)[i] = 0; - break; - } - } - - return SR_OK; -} - /** * Convert the unit/MQ/MQ flags in the analog struct to a string. *