From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 8E11142A83 for ; Tue, 12 Apr 2022 09:31:17 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DAACE68B3E1; Tue, 12 Apr 2022 12:31:14 +0300 (EEST) Received: from out203-205-221-231.mail.qq.com (out203-205-221-231.mail.qq.com [203.205.221.231]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0803968B356 for ; Tue, 12 Apr 2022 12:31:06 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649755862; bh=d0OHL8y+5WVzskgm4KEClj/q4a1+G0yqYlJCKn+kYvA=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=nTYsidSs/a8FHW9x5SxRuyhV3oUnuozZLk+5b34I7/9h2z70k3C2zeRlxGCBlZrmZ 7U0cZ0sYRX3G+aWRQS7Yb72/xbOiuC1Mgo6qDSSminport5WGcrHZWTL3z3G2soAx3 uvUErhiOARS53WsQ8dAnUoKZYHMAj2cAFoJxiSpg= Received: from [192.168.255.10] ([113.108.77.68]) by newxmesmtplogicsvrszc6.qq.com (NewEsmtp) with SMTP id 7C12D4EA; Tue, 12 Apr 2022 17:31:01 +0800 X-QQ-mid: xmsmtpt1649755861tyrx907nd Message-ID: X-QQ-XMAILINFO: N4CzT1PKe+qF4fsf4fDH584wBQCBQ8+bfZ0wcPKFR7I4qsk+6vJUz+/BmzDumM twnXBcaZbAoDTropl74BOTRY9LpyT3EG3WZQsBD0o/I1qLlBVcno83spVvqDzjeaYoC0KYPYBWm/ sdBIoAFphfMbb2/CQpS6Ih63Zhs3auzFgpvAoddscWtOMB1Wc8r+//QIws0YEmDbbkfwr+G0D6dU n4Ctv1bFMxQo528etJUAaOunDhPonl6OIX0a5qvilcASLJQCWGtQtjMnDri98TJaFKL+pL1w0WH9 DcczgGCskShDbAFyg1piy/+bWwTzUBfSf1MXFfYYOPBLKNqOmQmDRM66OPDH/8AlxDnaqPWSh+Yu uUxuQR7jJ35bmeDUFudIXFE8EoeMZ1nmoItNYTRqOnOcQkqRkoO8CcTBlfZRpVurWH9o58QRdfp/ gqBAQCyKi/0Mr0BmrtvwgqUCSmD9ulQwJAjxG68GpxMW+ZifY7X/dqHSyBg4fuoISuznY3q4YcS5 hxLVLzIzlTN0vWSphYncDOoXSWMfoaDQZ2tM+RHqGKB0t4yd6i9nHYaYtHJ7QiYXMBlT5Wmf3ixH RpSVbLzr5x2eyaOmKGHhCfGZCCq6yg6ol9ij8Ck3Vo5JZ8oMMDkoKbaRDFvEDiaEmo2kohhIxII2 tJu6eaJxf1FFaYuzNWoS0lVIY4UKjW4YWKk3ufCJAcF+/cuivWxVA+xZ9JWWeUvfw9PpQX3oKSbY cQsJn6ZnsXXDzabk616+ktf8GYBbfgbPgA4QZqgKOGgGHkgJUJsThixrex5FIPcNbiuMYXS9bFwJ u+MR8G1OGZ0d0OtSwZFUKyAf4qKb602Xo6Uf+ooTF0eADY+ewTGcwM/ftWrtU5DMhkVBfxoobo9M khZnB5yFXdbmakZ4Y96QxUgTHAroOQcAuMKDzh8hNFxhFXfrfbUvY= Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) From: =?utf-8?B?InpoaWxpemhhbyjotbXlv5fnq4spIg==?= In-Reply-To: Date: Tue, 12 Apr 2022 17:31:01 +0800 X-OQ-MSGID: References: To: FFmpeg development discussions and patches X-Mailer: Apple Mail (2.3654.60.0.2.21) Subject: Re: [FFmpeg-devel] [PATCH] avutil/mem: fix doc for reallocs X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Michael Niedermayer Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Ping. > On Apr 2, 2022, at 1:05 AM, Zhao Zhili wrote: > > The doc says those function are like av_free if size or nmemb is > zero. It doesn't match the code. av_realloc() realloc one byte if > size is zero, which was added by 91ff05f6ac5 ten years ago. > realloc() itself in C is implementation-dependent. Make the doc > match the longstanding behaviour. > --- > libavutil/mem.h | 23 +++++++++++------------ > 1 file changed, 11 insertions(+), 12 deletions(-) > > diff --git a/libavutil/mem.h b/libavutil/mem.h > index b9fe80738c..d91174196c 100644 > --- a/libavutil/mem.h > +++ b/libavutil/mem.h > @@ -250,8 +250,7 @@ void *av_mallocz_array(size_t nmemb, size_t size) av_malloc_attrib av_alloc_size > /** > * Allocate, reallocate, or free a block of memory. > * > - * If `ptr` is `NULL` and `size` > 0, allocate a new block. If `size` is > - * zero, free the memory block pointed to by `ptr`. Otherwise, expand or > + * If `ptr` is `NULL` and `size` > 0, allocate a new block. Otherwise, expand or > * shrink that block of memory according to `size`. > * > * @param ptr Pointer to a memory block already allocated with > @@ -260,10 +259,11 @@ void *av_mallocz_array(size_t nmemb, size_t size) av_malloc_attrib av_alloc_size > * reallocated > * > * @return Pointer to a newly-reallocated block or `NULL` if the block > - * cannot be reallocated or the function is used to free the memory block > + * cannot be reallocated > * > * @warning Unlike av_malloc(), the returned pointer is not guaranteed to be > - * correctly aligned. > + * correctly aligned. The returned pointer must be freed after even > + * if size is zero. > * @see av_fast_realloc() > * @see av_reallocp() > */ > @@ -311,8 +311,7 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize); > /** > * Allocate, reallocate, or free an array. > * > - * If `ptr` is `NULL` and `nmemb` > 0, allocate a new block. If > - * `nmemb` is zero, free the memory block pointed to by `ptr`. > + * If `ptr` is `NULL` and `nmemb` > 0, allocate a new block. > * > * @param ptr Pointer to a memory block already allocated with > * av_realloc() or `NULL` > @@ -320,19 +319,19 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize); > * @param size Size of the single element of the array > * > * @return Pointer to a newly-reallocated block or NULL if the block > - * cannot be reallocated or the function is used to free the memory block > + * cannot be reallocated > * > * @warning Unlike av_malloc(), the allocated memory is not guaranteed to be > - * correctly aligned. > + * correctly aligned. The returned pointer must be freed after even if > + * nmemb is zero. > * @see av_reallocp_array() > */ > av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size); > > /** > - * Allocate, reallocate, or free an array through a pointer to a pointer. > + * Allocate, reallocate an array through a pointer to a pointer. > * > - * If `*ptr` is `NULL` and `nmemb` > 0, allocate a new block. If `nmemb` is > - * zero, free the memory block pointed to by `*ptr`. > + * If `*ptr` is `NULL` and `nmemb` > 0, allocate a new block. > * > * @param[in,out] ptr Pointer to a pointer to a memory block already > * allocated with av_realloc(), or a pointer to `NULL`. > @@ -343,7 +342,7 @@ av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size) > * @return Zero on success, an AVERROR error code on failure > * > * @warning Unlike av_malloc(), the allocated memory is not guaranteed to be > - * correctly aligned. > + * correctly aligned. *ptr must be freed after even if nmemb is zero. > */ > int av_reallocp_array(void *ptr, size_t nmemb, size_t size); > > -- > 2.31.1 > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".