|
|
|
@ -37,6 +37,21 @@ static inline void *realloc_down( void *ptr, size_t size ) |
|
|
|
return ret ? ret : ptr; |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
|
* This wrapper around realloc() will free the input pointer when |
|
|
|
* realloc() returns NULL. The use case ptr = realloc(ptr, newsize) will |
|
|
|
* cause a memory leak when ptr pointed to a heap allocation before, |
|
|
|
* leaving the buffer allocated but unreferenced. vlc_realloc() is a |
|
|
|
* drop-in replacement for that use case (and only that use case). |
|
|
|
*/ |
|
|
|
static inline void *realloc_or_free( void *p, size_t sz ) |
|
|
|
{ |
|
|
|
void *n = realloc(p,sz); |
|
|
|
if( !n ) |
|
|
|
free(p); |
|
|
|
return n; |
|
|
|
} |
|
|
|
|
|
|
|
#define TAB_INIT( count, tab ) \ |
|
|
|
do { \ |
|
|
|
(count) = 0; \ |
|
|
|
|