开发者

How to remove buffer created in such way?

So I create buffer like

unsigned char *pb_buffer;

I fill it with some ffmpeg data from some older din buffer

    int len = url_close_dyn_buf(pFormatContext -> pb, (unsigned char **)(&pb_buffer));

I do some stuff with that data

Now I want to delete that buffer of mine. ow to do s开发者_开发问答uch thing?

I tried free(&pb_buffer); app dies... and brings me into some C++ doc I do not get...

I tried delete[] pb_buffer; os kills my app...


av_free(pb_buffer) perhaps? The function appears to be internal to ffmpeg, and its documentation indicates that you need to use av_free() to free the buffer it allocates.

The function is documented here.


unsigned char *pb_buffer doesn't create a buffer, it creates a pointer, which initially isn't pointing to anything. It's the call to url_close_dyn_buf that allocates the buffer, and stores a pointer to it in the place specified by its second argument.

The documentation for url_close_dyn_buf should tell you how to free it. The documentation is a bit sketchy, but av_free(pb_buffer) is the answer. The documentation for av_free recommends using av_freep(&pb_buffer) instead: that does the same thing and then sets pb_buffer to 0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜