diff --git a/doc/APIchanges b/doc/APIchanges index a9bf1afd4c8cc8a67ab24e11d97d07a910701632..c4a4471ecceb13436cb061462f17a7a5565e2a81 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +======= +2020-08-21 - xxxxxxxxxx - lavu 56.58.100 - avstring.h + Deprecate av_d2str(). Use av_asprintf() instead. + 2020-08-04 - xxxxxxxxxx - lavu 56.58.100 - channel_layout.h Add AV_CH_LAYOUT_22POINT2 together with its newly required pieces: AV_CH_TOP_SIDE_LEFT, AV_CH_TOP_SIDE_RIGHT, AV_CH_BOTTOM_FRONT_CENTER, diff --git a/libavutil/avstring.c b/libavutil/avstring.c index f4b8ed2b453a03535ffb4c0cb1c2c637058cf662..e33d4aac5199d6e13c5674f26026c3e727faf02c 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -136,6 +136,7 @@ end: return p; } +#if FF_API_D2STR char *av_d2str(double d) { char *str = av_malloc(16); @@ -143,6 +144,7 @@ char *av_d2str(double d) snprintf(str, 16, "%f", d); return str; } +#endif #define WHITESPACES " \n\t\r" diff --git a/libavutil/avstring.h b/libavutil/avstring.h index 274335cfb9c5a4edf5ccab031081d98b6238a618..ee225585b3dcd6c6e2f97124d9a2b026667e606a 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -24,6 +24,7 @@ #include <stddef.h> #include <stdint.h> #include "attributes.h" +#include "version.h" /** * @addtogroup lavu_string @@ -155,10 +156,14 @@ static inline size_t av_strnlen(const char *s, size_t len) */ char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2); +#if FF_API_D2STR /** * Convert a number to an av_malloced string. + * @deprecated use av_asprintf() with "%f" or a more specific format */ +attribute_deprecated char *av_d2str(double d); +#endif /** * Unescape the given string until a non escaped terminating char, diff --git a/libavutil/tests/avstring.c b/libavutil/tests/avstring.c index 887bd25a1266f8f6547cff99d3d761403011c207..37a2cf1833426a2329cbe59c9771fb3c1ced68f3 100644 --- a/libavutil/tests/avstring.c +++ b/libavutil/tests/avstring.c @@ -109,6 +109,8 @@ int main(void) TEST_STRIREPLACE(haystack, needle [2], "Education consists mainly in what we have instead."); TEST_STRIREPLACE(haystack, needle [1], "Education consists mainly in what we have instead"); +#if FF_API_D2STR +FF_DISABLE_DEPRECATION_WARNINGS /*Testing av_d2str()*/ #define TEST_D2STR(value, expected) \ if((ptr = av_d2str(value)) == NULL){ \ @@ -121,5 +123,7 @@ int main(void) TEST_D2STR(0 , "0.000000"); TEST_D2STR(-1.2333234, "-1.233323"); TEST_D2STR(-1.2333237, "-1.233324"); +FF_ENABLE_DEPRECATION_WARNINGS +#endif return 0; } diff --git a/libavutil/version.h b/libavutil/version.h index 3e7e1f410b146b023e35411961e0529166f77ccd..3f0a4a840250df587b4d916f07f6689a7c8fa1d6 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -132,6 +132,9 @@ #ifndef FF_API_CHILD_CLASS_NEXT #define FF_API_CHILD_CLASS_NEXT (LIBAVUTIL_VERSION_MAJOR < 57) #endif +#ifndef FF_API_D2STR +#define FF_API_D2STR (LIBAVUTIL_VERSION_MAJOR < 58) +#endif /** * @}