From patchwork Sun Jul 31 02:13:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timothy Gu X-Patchwork-Id: 37 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp2073171vsd; Sat, 30 Jul 2016 19:13:39 -0700 (PDT) X-Received: by 10.28.98.135 with SMTP id w129mr48987468wmb.38.1469931219336; Sat, 30 Jul 2016 19:13:39 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u1si25486741wjx.280.2016.07.30.19.13.38; Sat, 30 Jul 2016 19:13:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 42C49689C66; Sun, 31 Jul 2016 05:13:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pa0-f67.google.com (mail-pa0-f67.google.com [209.85.220.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C176B689C66 for ; Sun, 31 Jul 2016 05:13:06 +0300 (EEST) Received: by mail-pa0-f67.google.com with SMTP id cf3so7423483pad.2 for ; Sat, 30 Jul 2016 19:13:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9MvEXzAkV/Sys1j2TMTIv581EFVPFpe8p9CKxnquh1A=; b=ZIzkxaAhTlnL+MT3DSmGEr7Q7Q9q7EtIpZx1/4dWKZzOEN4jLhrnMmc1yMWwAOEl9v 5YZPbqLvde7qYRHbNFcV5eC0CgfgTogGecIMZVS/i/2dklgla/W3MfAOAPo9fjOMotsY 9ToXHxiTVONNRV19PpazaJ5zDjpZktfT4gHwleh6Jvr+pD8bZdTEqWsTXMykhBOagPXn 8y9+mx6Ze2VrIOulooWcN/751sHX7xYagK6EpaRJDWlTO/WJmuS2mIykGCGGCzGf9PmH MUcNEWj0YNLpwTWArFsNaOesATEgJcPs2CqHeJru/fqH4TggWLRCVFMRgW4osj2rNDS3 Vg3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9MvEXzAkV/Sys1j2TMTIv581EFVPFpe8p9CKxnquh1A=; b=L6mEjU1iGpoR+ftAsgkJJOaZy75SP/z8YlN/UrdXW047e1ZSBLpVZfRlkI4XBAQgQG 9gmdXkkDz/l2qh7ahPH9sAldTzSG5FCfTKndP/Dc2hDGWYOxTj6813tENuHxNW/GjpIQ sjd+3RkGZJvPlUcHIpSOGEHftgDo+ednoeDsbJmfZ2ihf/VM1BiCNu8UL3dlWvGjLlMB JFY6nIhngQNFIv+2VEbWXPvxN6OKN/tkVTJxyozB+qvLW8ceZlF/h+1cTAudJWlJq3aU L0Nzv46CTNFS4fS3aOhBg7RK7pMvnWRuuOP6nrpYLIRIjT6qz0SWuhIn8TOuEdcjfRu4 gTFg== X-Gm-Message-State: AEkoousaYzzat2nfUBIhh8P+HZBkgI+9Ape/cZF/pHPcTmawrKc475xcVnns8n8iyOV3Jg== X-Received: by 10.66.162.4 with SMTP id xw4mr82016914pab.97.1469931190085; Sat, 30 Jul 2016 19:13:10 -0700 (PDT) Received: from biggie.timothygu.me (ip68-5-186-115.oc.oc.cox.net. [68.5.186.115]) by smtp.gmail.com with ESMTPSA id q26sm35109957pfj.53.2016.07.30.19.13.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Jul 2016 19:13:09 -0700 (PDT) From: Timothy Gu To: ffmpeg-devel@ffmpeg.org Date: Sat, 30 Jul 2016 19:13:06 -0700 Message-Id: <1469931186-15509-1-git-send-email-timothygu99@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <20160730214916.GV5460@nb4> References: <20160730214916.GV5460@nb4> Subject: [FFmpeg-devel] [PATCH] mem: Make function attribute usage consistent 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 Cc: Timothy Gu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavutil/mem.h | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/libavutil/mem.h b/libavutil/mem.h index 2f53b47..a6bb6b7 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -80,7 +80,9 @@ * be allocated. * @see av_mallocz() */ -void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1); +av_malloc_attrib +av_alloc_size(1) +void *av_malloc(size_t size); /** * Allocate a block of size * nmemb bytes with av_malloc(). @@ -90,7 +92,9 @@ void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1); * be allocated. * @see av_malloc() */ -av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size) +av_malloc_attrib +av_alloc_size(1, 2) +static inline void *av_malloc_array(size_t nmemb, size_t size) { if (!size || nmemb >= INT_MAX / size) return NULL; @@ -115,7 +119,9 @@ av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t siz * some libc implementations. * @see av_fast_realloc() */ -void *av_realloc(void *ptr, size_t size) av_alloc_size(2); +av_malloc_attrib +av_alloc_size(2) +void *av_realloc(void *ptr, size_t size); /** * Allocate or reallocate a block of memory. @@ -125,6 +131,8 @@ void *av_realloc(void *ptr, size_t size) av_alloc_size(2); * - It frees the input block in case of failure, thus avoiding the memory * leak with the classic "buf = realloc(buf); if (!buf) return -1;". */ +av_malloc_attrib +av_alloc_size(2, 3) void *av_realloc_f(void *ptr, size_t nelem, size_t elsize); /** @@ -145,6 +153,7 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize); * some libc implementations. */ av_warn_unused_result +av_alloc_size(2) int av_reallocp(void *ptr, size_t size); /** @@ -164,7 +173,9 @@ int av_reallocp(void *ptr, size_t size); * The situation is undefined according to POSIX and may crash with * some libc implementations. */ -av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size); +av_malloc_attrib +av_alloc_size(2, 3) +void *av_realloc_array(void *ptr, size_t nmemb, size_t size); /** * Allocate or reallocate an array through a pointer to a pointer. @@ -183,7 +194,8 @@ av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size) * The situation is undefined according to POSIX and may crash with * some libc implementations. */ -av_alloc_size(2, 3) int av_reallocp_array(void *ptr, size_t nmemb, size_t size); +av_alloc_size(2, 3) +int av_reallocp_array(void *ptr, size_t nmemb, size_t size); /** * Free a memory block which has been allocated with av_malloc(z)() or @@ -203,7 +215,9 @@ void av_free(void *ptr); * @return Pointer to the allocated block, NULL if it cannot be allocated. * @see av_malloc() */ -void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1); +av_malloc_attrib +av_alloc_size(1) +void *av_mallocz(size_t size); /** * Allocate a block of nmemb * size bytes with alignment suitable for all @@ -215,7 +229,9 @@ void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1); * @param size * @return Pointer to the allocated block, NULL if it cannot be allocated. */ -void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib; +av_malloc_attrib +av_alloc_size(1, 2) +void *av_calloc(size_t nmemb, size_t size); /** * Allocate a block of size * nmemb bytes with av_mallocz(). @@ -226,7 +242,9 @@ void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib; * @see av_mallocz() * @see av_malloc_array() */ -av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size) +av_malloc_attrib +av_alloc_size(1, 2) +static inline void *av_mallocz_array(size_t nmemb, size_t size) { if (!size || nmemb >= INT_MAX / size) return NULL; @@ -239,7 +257,8 @@ av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t si * @return Pointer to a newly-allocated string containing a * copy of s or NULL if the string cannot be allocated. */ -char *av_strdup(const char *s) av_malloc_attrib; +av_malloc_attrib +char *av_strdup(const char *s); /** * Duplicate a substring of the string s. @@ -249,7 +268,9 @@ char *av_strdup(const char *s) av_malloc_attrib; * @return Pointer to a newly-allocated string containing a * copy of s or NULL if the string cannot be allocated. */ -char *av_strndup(const char *s, size_t len) av_malloc_attrib; +av_malloc_attrib +av_alloc_size(2) +char *av_strndup(const char *s, size_t len); /** * Duplicate the buffer p. @@ -257,6 +278,8 @@ char *av_strndup(const char *s, size_t len) av_malloc_attrib; * @return Pointer to a newly allocated buffer containing a * copy of p or NULL if the buffer cannot be allocated. */ +av_malloc_attrib +av_alloc_size(2) void *av_memdup(const void *p, size_t size); /** @@ -368,6 +391,8 @@ void av_memcpy_backptr(uint8_t *dst, int back, int cnt); * * @see av_realloc */ +av_malloc_attrib +av_alloc_size(3) void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size); /** @@ -382,6 +407,7 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size); * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and * *size 0 if an error occurred. */ +av_alloc_size(3) void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size); /** @@ -397,6 +423,7 @@ void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size); * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and * *size 0 if an error occurred. */ +av_alloc_size(3) void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size); /**