[FFmpeg-devel] [PATCH v2 1/1] avformat: Add IPFS protocol support.
Timo Rothenpieler
timo at rothenpieler.org
Wed Feb 2 16:24:01 EET 2022
On 02.02.2022 14:56, Mark Gaiser wrote:
> On Wed, Feb 2, 2022 at 2:21 PM Tomas Härdin <tjoppen at acc.umu.se> wrote:
>
>> tis 2022-02-01 klockan 22:58 +0100 skrev Mark Gaiser:
>>
>>>
>>> +typedef struct Context {
>>> + AVClass *class;
>>> + URLContext *inner;
>>> + char *gateway;
>>
>> Is there not a maximum length that an HTTP URL can be? At least without
>> query parameters. That way you avoid dynamic allocations. You'd have to
>> separate the AVOption from such a buffer in that case, but I think you
>> have to anyway.
>>
>
> Could you provide more information on that? Or an example of what you mean
> exactly?
> As far as i know there is no hard limit though it's very much advised to
> not go above 2048 characters.
>
>>
>>> + if (!ipfs_full_data_folder) {
>>> + av_log(h, AV_LOG_DEBUG, "$IPFS_PATH is empty.\n");
>>> +
>>> + // Try via the home folder.
>>> + home_folder = getenv("HOME");
>>> + ipfs_full_data_folder = av_asprintf("%s/.ipfs/",
>>> home_folder);
>>
>> Memory leak. This applies to most if not all av_asprintf() calls.
>>
>
> Is there an advised way to neatly clean that up?
> Sure, I can add a bunch of av_free calls to clean it up. But there are
> places where it's not as straightforward like where the av_asprintf was
> done in an if statement. How do I maintain the knowledge that av_asprintf
> was used to call av_free later?
> In a C++ world I'd use a scoped variable ;) But I kinda miss how to do that
> properly here.
You typically make a "goto error" style thing, where you free everything
that might have been allocated.
Freeing a NULL pointer is valid and does not cause issues, so just
properly initialize the pointers and av_freep() them on error.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4494 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20220202/45e99707/attachment.bin>
More information about the ffmpeg-devel
mailing list