avio: Add an internal utility function for freeing dynamic buffers

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö 2015-02-24 13:23:30 +02:00
parent 078d43e23a
commit 8a273a7460
2 changed files with 17 additions and 0 deletions

View File

@ -139,4 +139,11 @@ int ffio_open_null_buf(AVIOContext **s);
*/
int ffio_close_null_buf(AVIOContext *s);
/**
* Free a dynamic buffer.
*
* @param s a pointer to an IO context opened by avio_open_dyn_buf()
*/
void ffio_free_dyn_buf(AVIOContext **s);
#endif /* AVFORMAT_AVIO_INTERNAL_H */

View File

@ -991,6 +991,16 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
return size - padding;
}
void ffio_free_dyn_buf(AVIOContext **s)
{
uint8_t *tmp;
if (!*s)
return;
avio_close_dyn_buf(*s, &tmp);
av_free(tmp);
*s = NULL;
}
static int null_buf_write(void *opaque, uint8_t *buf, int buf_size)
{
DynBuffer *d = opaque;