X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fcache.c;h=3e60aea48fbea0041f924856b6b796ea35ffb577;hb=0be8e661743705eb4c4369943867f462df0fa1ca;hp=c2bddf5f6d5a826784788a6c9358d68e7e87519a;hpb=7876f14f8be9d78de1875ff38390d2a37ac86ec3;p=ffmpeg diff --git a/libavformat/cache.c b/libavformat/cache.c index c2bddf5f6d5..3e60aea48fb 100644 --- a/libavformat/cache.c +++ b/libavformat/cache.c @@ -51,15 +51,8 @@ typedef struct Context { static int cache_open(URLContext *h, const char *arg, int flags) { - int access; const char *buffername; - Context *c; - - c = av_mallocz(sizeof(Context)); - if (!c) { - return AVERROR(ENOMEM); - } - h->priv_data = c; + Context *c= h->priv_data; av_strstart(arg, "cache:", &arg); @@ -70,7 +63,7 @@ static int cache_open(URLContext *h, const char *arg, int flags) } unlink(buffername); - av_free(buffername); + av_freep(&buffername); return ffurl_open(&c->inner, arg, flags, &h->interrupt_callback, NULL); } @@ -130,8 +123,6 @@ static int cache_close(URLContext *h) close(c->fd); ffurl_close(c->inner); - av_freep(&h->priv_data); - return 0; } @@ -141,4 +132,5 @@ URLProtocol ff_cache_protocol = { .url_read = cache_read, .url_seek = cache_seek, .url_close = cache_close, + .priv_data_size = sizeof(Context), };