VLC  3.0.15
Files | Functions
Memory

Files

file  vlc_memory.h
 

Functions

static void * realloc_or_free (void *p, size_t sz)
 This wrapper around realloc() will free the input pointer when realloc() returns NULL. More...
 

Detailed Description

Function Documentation

◆ realloc_or_free()

static void* realloc_or_free ( void *  p,
size_t  sz 
)
inlinestatic

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

References p.

Referenced by vlc_config_create(), and vlc_stream_ReadLine().