VLC  3.0.15
Data Structures | Functions
objres.c File Reference
Include dependency graph for objres.c:

Data Structures

struct  vlc_res
 

Functions

static struct vlc_res ** vlc_obj_res (vlc_object_t *obj)
 
void * vlc_objres_new (size_t size, void(*release)(void *))
 Allocates an object resource. More...
 
void vlc_objres_push (vlc_object_t *obj, void *data)
 Pushes an object resource on the object resources stack. More...
 
static void * vlc_objres_pop (vlc_object_t *obj)
 
void vlc_objres_clear (vlc_object_t *obj)
 Releases all resources of an object. More...
 
void vlc_objres_remove (vlc_object_t *obj, void *data, bool(*match)(void *, void *))
 Releases one object resource explicitly. More...
 
static void dummy_release (void *data)
 
static bool ptrcmp (void *a, void *b)
 
void * vlc_obj_malloc (vlc_object_t *obj, size_t size)
 
static void * vlc_obj_alloc_common (vlc_object_t *obj, size_t nmemb, size_t size, bool do_memset)
 
void * vlc_obj_calloc (vlc_object_t *obj, size_t nmemb, size_t size)
 
void vlc_obj_free (vlc_object_t *obj, void *ptr)
 

Function Documentation

◆ dummy_release()

static void dummy_release ( void *  data)
static

◆ ptrcmp()

static bool ptrcmp ( void *  a,
void *  b 
)
static

Referenced by vlc_obj_free().

◆ vlc_obj_alloc_common()

static void* vlc_obj_alloc_common ( vlc_object_t obj,
size_t  nmemb,
size_t  size,
bool  do_memset 
)
static

◆ vlc_obj_res()

static struct vlc_res** vlc_obj_res ( vlc_object_t obj)
static

◆ vlc_objres_clear()

void vlc_objres_clear ( vlc_object_t obj)

Releases all resources of an object.

All resources added with vlc_objres_add() are released in reverse order. The resource list is reset to empty.

Parameters
objobject whose resources to release

References container_of, vlc_res::payload, vlc_res::release, and vlc_objres_pop().

Referenced by module_load(), and vlc_module_unload().

◆ vlc_objres_new()

void* vlc_objres_new ( size_t  size,
void(*)(void *)  release 
)

Allocates an object resource.

Parameters
sizestorage size in bytes of the resource data
releasecallback to release the resource
Returns
a pointer to the (uninitialized) storage space, or NULL on error

References add_overflow, and unlikely.

Referenced by vlc_obj_alloc_common(), and vlc_obj_malloc().

◆ vlc_objres_pop()

static void* vlc_objres_pop ( vlc_object_t obj)
static

◆ vlc_objres_push()

void vlc_objres_push ( vlc_object_t obj,
void *  data 
)

Pushes an object resource on the object resources stack.

Parameters
objobject to allocate the resource for
dataresource base address (as returned by vlc_objres_new())

References container_of, vlc_res::payload, vlc_res::prev, and vlc_obj_res().

Referenced by vlc_obj_alloc_common(), and vlc_obj_malloc().

◆ vlc_objres_remove()

void vlc_objres_remove ( vlc_object_t obj,
void *  data,
bool(*)(void *, void *)  match 
)

Releases one object resource explicitly.

If a resource associated with an object needs to be released explicitly earlier than normal, call this function. This is relatively slow and should be avoided.

Parameters
objobject whose resource to release
dataprivate data for the comparison function
matchcomparison function to match the targeted resource

References vlc_res::payload, vlc_res::prev, vlc_res::release, and vlc_obj_res().

Referenced by vlc_obj_free().