diff --git a/libobs/util/bmem.c b/libobs/util/bmem.c index de60498de..e7017c7e3 100644 --- a/libobs/util/bmem.c +++ b/libobs/util/bmem.c @@ -87,19 +87,13 @@ static void a_free(void *ptr) #endif } -static struct base_allocator alloc = {a_malloc, a_realloc, a_free}; static long num_allocs = 0; -void base_set_allocator(struct base_allocator *defs) -{ - memcpy(&alloc, defs, sizeof(struct base_allocator)); -} - void *bmalloc(size_t size) { - void *ptr = alloc.malloc(size); + void *ptr = a_malloc(size); if (!ptr && !size) - ptr = alloc.malloc(1); + ptr = a_malloc(1); if (!ptr) { os_breakpoint(); bcrash("Out of memory while trying to allocate %lu bytes", @@ -115,9 +109,9 @@ void *brealloc(void *ptr, size_t size) if (!ptr) os_atomic_inc_long(&num_allocs); - ptr = alloc.realloc(ptr, size); + ptr = a_realloc(ptr, size); if (!ptr && !size) - ptr = alloc.realloc(ptr, 1); + ptr = a_realloc(ptr, 1); if (!ptr) { os_breakpoint(); bcrash("Out of memory while trying to allocate %lu bytes", @@ -131,7 +125,7 @@ void bfree(void *ptr) { if (ptr) { os_atomic_dec_long(&num_allocs); - alloc.free(ptr); + a_free(ptr); } } @@ -153,3 +147,5 @@ void *bmemdup(const void *ptr, size_t size) return out; } + +OBS_DEPRECATED void base_set_allocator(struct base_allocator *defs) {} diff --git a/libobs/util/bmem.h b/libobs/util/bmem.h index ce0293ef8..c01afd92b 100644 --- a/libobs/util/bmem.h +++ b/libobs/util/bmem.h @@ -31,7 +31,7 @@ struct base_allocator { void (*free)(void *); }; -EXPORT void base_set_allocator(struct base_allocator *defs); +OBS_DEPRECATED EXPORT void base_set_allocator(struct base_allocator *defs); EXPORT void *bmalloc(size_t size); EXPORT void *brealloc(void *ptr, size_t size);