VLC 4.0.0-dev
|
The object resource functions tie resource allocation to an instance of a module through a VLC object. More...
Macros | |
#define | vlc_obj_malloc(o, s) vlc_obj_malloc(VLC_OBJECT(o), s) |
#define | vlc_obj_calloc(o, n, s) vlc_obj_calloc(VLC_OBJECT(o), n, s) |
#define | vlc_obj_strdup(o, s) vlc_obj_strdup(VLC_OBJECT(o), s) |
#define | vlc_obj_free(o, p) vlc_obj_free(VLC_OBJECT(o), p) |
Functions | |
void * | vlc_obj_malloc (vlc_object_t *obj, size_t size) |
Allocates memory for a module. | |
void * | vlc_obj_calloc (vlc_object_t *obj, size_t nmemb, size_t size) |
Allocates a zero-initialized table for a module. | |
char * | vlc_obj_strdup (vlc_object_t *obj, const char *str) |
Duplicates a string for a module. | |
void | vlc_obj_free (vlc_object_t *obj, void *ptr) |
Manually frees module memory. | |
The object resource functions tie resource allocation to an instance of a module through a VLC object.
Such resource will be automatically freed, in first in last out order, when the module instance associated with the VLC object is terminated.
Specifically, if the module instance activation/probe function fails, the resource will be freed immediately after the failure. If the activation succeeds, the resource will be freed when the module instance is terminated.
This is a convenience mechanism to save explicit clean-up function calls in modules.
#define vlc_obj_calloc | ( | o, | |
n, | |||
s | |||
) | vlc_obj_calloc(VLC_OBJECT(o), n, s) |
#define vlc_obj_free | ( | o, | |
p | |||
) | vlc_obj_free(VLC_OBJECT(o), p) |
#define vlc_obj_malloc | ( | o, | |
s | |||
) | vlc_obj_malloc(VLC_OBJECT(o), s) |
#define vlc_obj_strdup | ( | o, | |
s | |||
) | vlc_obj_strdup(VLC_OBJECT(o), s) |
void * vlc_obj_calloc | ( | vlc_object_t * | obj, |
size_t | nmemb, | ||
size_t | size | ||
) |
Allocates a zero-initialized table for a module.
This function allocates a table from the heap for a module instance. The memory is initialized to all zeroes.
obj | VLC object to tie the memory allocation to |
nmemb | number of table entries |
size | byte size of a table entry |
References likely, unlikely, and vlc_obj_malloc.
void vlc_obj_free | ( | vlc_object_t * | obj, |
void * | ptr | ||
) |
Manually frees module memory.
This function manually frees a resource allocated with vlc_obj_malloc(), vlc_obj_calloc() or vlc_obj_strdup() before the module instance is terminated. This is seldom necessary.
obj | VLC object that the allocation was tied to |
ptr | pointer to the allocated resource |
References ptrcmp(), and vlc_objres_remove().
void * vlc_obj_malloc | ( | vlc_object_t * | obj, |
size_t | size | ||
) |
Allocates memory for a module.
This function allocates memory from the heap for a module instance. The memory is uninitialized.
obj | VLC object to tie the memory allocation to |
size | byte size of the memory allocation |
References dummy_release(), likely, vlc_objres_new(), and vlc_objres_push().
char * vlc_obj_strdup | ( | vlc_object_t * | obj, |
const char * | str | ||
) |
Duplicates a string for a module.
This function allocates a copy of a nul-terminated string for a module instance.
obj | VLC object to tie the memory allocation to |
str | string to copy |
References vlc_obj_memdup().