[FFmpeg-devel] [PATCH v2 1/1] avformat: Add IPFS protocol support.

Mark Gaiser markg85 at gmail.com
Wed Feb 2 16:39:06 EET 2022


On Wed, Feb 2, 2022 at 3:24 PM Timo Rothenpieler <timo at rothenpieler.org>
wrote:

> 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.
>

Awesome! Thank you for explaining it, fixing it now.


> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list