Commit 13c5935c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

objres: add vlc_obj_strdup()

parent 83a40671
......@@ -139,6 +139,7 @@ VLC_API char *vlc_object_get_name( const vlc_object_t * ) VLC_USED;
VLC_API VLC_MALLOC void *vlc_obj_malloc(vlc_object_t *, size_t);
VLC_API VLC_MALLOC void *vlc_obj_calloc(vlc_object_t *, size_t, size_t);
VLC_API VLC_MALLOC char *vlc_obj_strdup(vlc_object_t *, const char *);
VLC_API void vlc_obj_free(vlc_object_t *, void *);
/** @} */
......@@ -273,6 +273,7 @@ vlc_strerror
vlc_strerror_c
vlc_obj_malloc
vlc_obj_calloc
vlc_obj_strdup
vlc_obj_free
msleep
mwait
......
......@@ -26,6 +26,7 @@
#include <errno.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <vlc_common.h>
......@@ -166,6 +167,19 @@ void *vlc_obj_calloc(vlc_object_t *obj, size_t nmemb, size_t size)
return vlc_obj_alloc_common(obj, nmemb, size, true);
}
static void *vlc_obj_memdup(vlc_object_t *obj, const void *base, size_t len)
{
void *ptr = vlc_obj_malloc(obj, len);
if (likely(ptr != NULL))
memcpy(ptr, base, len);
return ptr;
}
char *vlc_obj_strdup(vlc_object_t *obj, const char *str)
{
return vlc_obj_memdup(obj, str, strlen(str) + 1);
}
void vlc_obj_free(vlc_object_t *obj, void *ptr)
{
vlc_objres_remove(obj, ptr, ptrcmp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment