|
@@ -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) {}
|