From patchwork Thu Dec 22 00:45:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 1883 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp398177vsb; Wed, 21 Dec 2016 16:52:02 -0800 (PST) X-Received: by 10.194.43.73 with SMTP id u9mr6685466wjl.109.1482367922812; Wed, 21 Dec 2016 16:52:02 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b79si25957799wma.103.2016.12.21.16.51.59; Wed, 21 Dec 2016 16:52:02 -0800 (PST) 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 91C9968A397; Thu, 22 Dec 2016 02:51:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f196.google.com (mail-qt0-f196.google.com [209.85.216.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B7D8868A21C for ; Thu, 22 Dec 2016 02:51:49 +0200 (EET) Received: by mail-qt0-f196.google.com with SMTP id n6so28809486qtd.0 for ; Wed, 21 Dec 2016 16:51:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to; bh=67PV2p/v6j6w5AI3ZP39uVWc7Eo/kQB/e5zekrASqpc=; b=rnTT5VQaVLSEBPV1E1rnXtWsM67gduDOfjKpmSWEoGy/gdNWx7CfnQqgBVO5ds7h2o MYT5aIQeZwNA4ZWW+t/Ik7ToHJdZ7Sfa4rraG2J0zMjN4eUWqZVCaz466z+2auLazDHf CdiNbvmIfrTeVgsWSrsxL0I0lRP/36PZx/dF0JO/Qw6ku4Dgvg4Ae547fu8HXSUbqhj4 rFoUgy/IqQB+Q2S/+9zungdKiRQZJ7mVHomX1V2EzOORF6q68WVODf8BhiPm9lWEB/hi 1lwZRaJBdMinDu6rBlfrRyvbwtOOI+X8UBNbiA6yYqm03Uuf9AKKGFJ3M3XLWfrkC/oG SrjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to; bh=67PV2p/v6j6w5AI3ZP39uVWc7Eo/kQB/e5zekrASqpc=; b=Rg7czQyxGI/3ytAHf/HWkcplR6dvZmC2C0AgC39DOCQk/LIKFPJiTLv5vdfWg8miFO 5Y3q/ShLUZf35l9bkoBRWg95OsazEXkZVoiHxFN3D7lQryumvBLLTTErjXKIBtuHD0YB sCjayey+h1BRRVU+N3CIp6FsOyfM4aby10I3s25by44hTHmvKuIYBMaHKw/UwEZd7ooh tsqk51l786e58FdfoAsMaod0+KqOArSxkJK4AibPMYO75ygk1rAdkhLAdVLW8kUzDpcq rgQfW4VUonxKjef1S2OQyBP+xmaagW9Fk0d/VpcBiL9LcrGLpJhEvzV6+6rZp2J98DmD CEOQ== X-Gm-Message-State: AIkVDXJtlzbbIGvx20MDjdT6eJAqYjRNZKeGvLKIiGfkfFHK6pgpSd7aOpKbZ94Li3izgA== X-Received: by 10.237.37.149 with SMTP id x21mr7346295qtc.148.1482367550244; Wed, 21 Dec 2016 16:45:50 -0800 (PST) Received: from [192.168.1.33] ([181.22.48.246]) by smtp.googlemail.com with ESMTPSA id 7sm6176461qkx.49.2016.12.21.16.45.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Dec 2016 16:45:49 -0800 (PST) To: FFmpeg development discussions and patches References: <1482281631-20093-1-git-send-email-thomastdt@googlemail.com> <20161221023606.GE4749@nb4> From: James Almer Message-ID: Date: Wed, 21 Dec 2016 21:45:39 -0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20161221023606.GE4749@nb4> Subject: Re: [FFmpeg-devel] [PATCH] avutil: Added selftest for libavutil/audio_fifo.c 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" On 12/20/2016 11:36 PM, Michael Niedermayer wrote: > On Tue, Dec 20, 2016 at 04:53:51PM -0800, Thomas Turner wrote: >> Signed-off-by: Thomas Turner >> --- >> libavutil/Makefile | 1 + >> libavutil/tests/audio_fifo.c | 196 +++++++++++++++++++++++++++++++++++++ >> tests/fate/libavutil.mak | 4 + >> tests/ref/fate/audio_fifo | 228 +++++++++++++++++++++++++++++++++++++++++++ >> 4 files changed, 429 insertions(+) >> create mode 100644 libavutil/tests/audio_fifo.c >> create mode 100644 tests/ref/fate/audio_fifo > > applied > > thx This is crashing on some fate clients. I noticed it's using malloc and free instead of the av_malloc family, so maybe it's related to that? Patch attached in any case, it's proper even if not the reason behind the crashes. From 61898e2580a67250cb3e1fb25a4e170fd00feada Mon Sep 17 00:00:00 2001 From: James Almer Date: Wed, 21 Dec 2016 21:41:20 -0300 Subject: [PATCH] test/audio_fifo: use av_malloc() family of functions Signed-off-by: James Almer --- libavutil/tests/audio_fifo.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/libavutil/tests/audio_fifo.c b/libavutil/tests/audio_fifo.c index dbadded..e9b1470 100644 --- a/libavutil/tests/audio_fifo.c +++ b/libavutil/tests/audio_fifo.c @@ -19,6 +19,7 @@ #include #include #include +#include "libavutil/mem.h" #include "libavutil/audio_fifo.c" #define MAX_CHANNELS 32 @@ -50,15 +51,6 @@ static void ERROR(const char *str) exit(1); } -static void* allocate_memory(size_t size) -{ - void *ptr = malloc(size); - if (ptr == NULL){ - ERROR("failed to allocate memory!"); - } - return ptr; -} - static void print_audio_bytes(const TestStruct *test_sample, void **data_planes, int nb_samples) { int p, b, f; @@ -85,11 +77,15 @@ static int read_samples_from_audio_fifo(AVAudioFifo* afifo, void ***output, int int samples = FFMIN(nb_samples, afifo->nb_samples); int tot_elements = !(planes = av_sample_fmt_is_planar(afifo->sample_fmt)) ? samples : afifo->channels * samples; - void **data_planes = allocate_memory(sizeof(void*) * planes); + void **data_planes = av_malloc_array(planes, sizeof(void*)); + if (!data_planes) + ERROR("failed to allocate memory!"); *output = data_planes; for (i = 0; i < afifo->nb_buffers; ++i){ - data_planes[i] = allocate_memory(afifo->sample_size * tot_elements); + data_planes[i] = av_malloc_array(tot_elements, afifo->sample_size); + if (!data_planes[i]) + ERROR("failed to allocate memory!"); } return av_audio_fifo_read(afifo, *output, nb_samples); @@ -178,9 +174,9 @@ static void test_function(const TestStruct test_sample) /* deallocate */ for (i = 0; i < afifo->nb_buffers; ++i){ - free(output_data[i]); + av_freep(&output_data[i]); } - free(output_data); + av_freep(&output_data); av_audio_fifo_free(afifo); } -- 2.10.2