From patchwork Thu Dec 26 18:40:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 16983 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 0957644A1BA for ; Thu, 26 Dec 2019 20:41:05 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DFD2E68A78A; Thu, 26 Dec 2019 20:41:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1DECD6880DC for ; Thu, 26 Dec 2019 20:40:58 +0200 (EET) X-ENS-nef-client: 129.199.129.80 Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id xBQIesR6024088 for ; Thu, 26 Dec 2019 19:40:55 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id BBF48E6C30; Thu, 26 Dec 2019 19:40:54 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Dec 2019 19:40:50 +0100 Message-Id: <20191226184051.156086-1-george@nsup.org> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Thu, 26 Dec 2019 19:40:55 +0100 (CET) Subject: [FFmpeg-devel] [PATCH] lavu/avstring: deprecate av_d2str(). X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It is no longer used in our code base and does not seem to be used much in other projects. Signed-off-by: Nicolas George --- doc/APIchanges | 3 +++ libavutil/avstring.c | 2 ++ libavutil/avstring.h | 5 +++++ libavutil/tests/avstring.c | 4 ++++ libavutil/version.h | 3 +++ 5 files changed, 17 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index 5b8d801f06..a22932c8f2 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2019-12-xx - xxxxxxxxxx - lavu 56.37.100 - avstring.h + Deprecate av_d2str(). Use av_asprintf() instead. + 2019-12-xx - xxxxxxxxxx - lavu 56.37.100 - buffer.h Add av_buffer_pool_buffer_get_opaque(). diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 76a13ba3b5..f6f7ab568e 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 274335cfb9..ee225585b3 100644 --- a/libavutil/avstring.h +++ b/libavutil/avstring.h @@ -24,6 +24,7 @@ #include #include #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 887bd25a12..37a2cf1833 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 4de0fa1fc3..835206a8ff 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -129,6 +129,9 @@ #ifndef FF_API_PSEUDOPAL #define FF_API_PSEUDOPAL (LIBAVUTIL_VERSION_MAJOR < 57) #endif +#ifndef FF_API_D2STR +#define FF_API_D2STR (LIBAVUTIL_VERSION_MAJOR < 57) +#endif /**