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 52B05402A6 for ; Mon, 20 Dec 2021 08:01:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2875068AEEC; Mon, 20 Dec 2021 10:01:51 +0200 (EET) Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8899368A22C for ; Mon, 20 Dec 2021 10:01:45 +0200 (EET) Received: by mail-ua1-f43.google.com with SMTP id p2so16127212uad.11 for ; Mon, 20 Dec 2021 00:01:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=mssrf7zHXQLk57cfGipq63VCHYTN+bbbdBSs8dl0v7o=; b=SvmzJCqyoDgymUOjROM3gQ6PMSXslQPxvz81jRz5uRxvde3a/+PCM2LKDzvNoHvRuA IPEx8maNd9XQdfVk6vCotYLXg/fYBZNkspXxtAw1+gfgW9uVBEjXZSGQvS54CQMaBE+m O7mWuV7352hl3ebGbHFw9out8D571BquafZIKnIhI7P5oixcV/jZGvpA/BEfxzzNVpQY TKHdYh6qmndXfuw2sqXXBR1pwdujNdAW0NZ84UmJRSGjGPGVqRB7YlbrpXabGEtuSHRB J5NH0jm/mdmSu3gqoIvaN6Z/8THyJHifgEp4TOaszRXAiy80Siohr6d6hi2B2JKcdqaT WvXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=mssrf7zHXQLk57cfGipq63VCHYTN+bbbdBSs8dl0v7o=; b=Ds47yXGbV4gjgvBmo9OJUIouoiFuP4xIZiHqCgk4JoFyJJUECxoEdJ2qj+ZwwzfgBE iOWAIcHmzx8b08RKrkLJv/uE35kl+Z/oaNfpmcvpiyvONHDs7p04yGgmx7VlWEwaFNAg zSrALN18QbPdysNKAjvEuJrgqzf50cuSZf9xWrQ9srW6W8Z2KInbb59dftlaQQNE7bAf 5hh4dqM5x0UYQ7d62vwBiWqzZkbL3GEpm2rBBC+7xvG6xWH0sz50cQRxS+iNqBBCemIf WLHnaRtf+Rw5OLAesJcg7gouv0miwpTRUj+G9AagCiRXcj8UJJO2sOg+1KuxjihyhuZx 6D1w== X-Gm-Message-State: AOAM532LIFyNEhTPjByxkZjkTQrkTNTd45rUzxQpffbouG02dt01eGNe 9A4zgZ+X2ZithIOIiPU8OdV7tavtYPHCajTouN07beNZ5oyJAw== X-Google-Smtp-Source: ABdhPJyxN1iQ6/NrV7JRsMHDnnzKixuNCZtSAycAp3jf6AkxRrzBAOQ8hsgvWLNEm9IVmeYDt3vtz0Feqy7YLiAKduQ= X-Received: by 2002:a67:c29a:: with SMTP id k26mr4578262vsj.32.1639987303903; Mon, 20 Dec 2021 00:01:43 -0800 (PST) MIME-Version: 1.0 References: <20211219192134.1296-1-dcnieho@gmail.com> <20211219192134.1296-11-dcnieho@gmail.com> In-Reply-To: From: "Diederick C. Niehorster" Date: Mon, 20 Dec 2021 09:01:27 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH v5 10/13] avdevice/dshow: add media type info to get_device_list 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 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: On Mon, Dec 20, 2021 at 2:04 AM Andreas Rheinhardt wrote: > > Diederick Niehorster: > > // store to device_list output > > if (av_reallocp_array(&(*device_list)->devices, > > (*device_list)->nb_devices + 1, > > @@ -412,6 +417,8 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, > > av_freep(&device->device_name); > > if (device->device_name) > > av_freep(&device->device_description); > > + if (device->media_types) > > + av_freep(&device->media_types); > > You are duplicating freeing code here: You have code to free media_types > both before it was put into device and after; you can avoid the latter > by only attaching media_types to device when nothing else can fail. I could indeed avoid adding av_freep(&device->media_types) when only attaching media_types to the device once it made it into the device list array (so doing (*device_list)->devices[(*device_list)->nb_devices]->media_types = media_types). But that makes the code harder to read (asymmetric, everything else is attached to the device before it goes into the list) and the missing free while the other device members are freed looks like a code smell. I think this is easier to read and less error prone for future patches when done as currently. Thanks! Dee _______________________________________________ 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".