[vlc-commits] objres: inline vlc_obj_alloc_common()
Rémi Denis-Courmont
git at videolan.org
Wed Jul 4 21:08:38 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul 2 22:09:26 2018 +0300| [d6cd9903eb82224948e7c7cdb3ceff2c366c3ba2] | committer: Rémi Denis-Courmont
objres: inline vlc_obj_alloc_common()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d6cd9903eb82224948e7c7cdb3ceff2c366c3ba2
---
src/misc/objres.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/src/misc/objres.c b/src/misc/objres.c
index c5c3d96711..cac8624e7e 100644
--- a/src/misc/objres.c
+++ b/src/misc/objres.c
@@ -142,31 +142,21 @@ void *vlc_obj_malloc(vlc_object_t *obj, size_t size)
return ptr;
}
-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)
{
size_t tabsize;
- if (mul_overflow(nmemb, size, &tabsize))
+ if (unlikely(mul_overflow(nmemb, size, &tabsize)))
{
errno = ENOMEM;
return NULL;
}
- void *ptr = vlc_objres_new(tabsize, dummy_release);
+ void *ptr = vlc_obj_malloc(obj, tabsize);
if (likely(ptr != NULL))
- {
- if (do_memset)
- memset(ptr, 0, tabsize);
- vlc_objres_push(obj, ptr);
- }
+ memset(ptr, 0, tabsize);
return ptr;
}
-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);
More information about the vlc-commits
mailing list