libobs/util: Breakpoint crash on "out of memory"

This forces proper crash handling to generate a stack trace.
master
jp9000 2015-11-18 12:22:56 -08:00
parent fa5c477826
commit 52d5a9b0b4
1 changed files with 7 additions and 2 deletions

View File

@ -18,6 +18,7 @@
#include <string.h>
#include "base.h"
#include "bmem.h"
#include "platform.h"
#include "threading.h"
/*
@ -97,9 +98,11 @@ void *bmalloc(size_t size)
void *ptr = alloc.malloc(size);
if (!ptr && !size)
ptr = alloc.malloc(1);
if (!ptr)
if (!ptr) {
os_breakpoint();
bcrash("Out of memory while trying to allocate %lu bytes",
(unsigned long)size);
}
os_atomic_inc_long(&num_allocs);
return ptr;
@ -113,9 +116,11 @@ void *brealloc(void *ptr, size_t size)
ptr = alloc.realloc(ptr, size);
if (!ptr && !size)
ptr = alloc.realloc(ptr, 1);
if (!ptr)
if (!ptr) {
os_breakpoint();
bcrash("Out of memory while trying to allocate %lu bytes",
(unsigned long)size);
}
return ptr;
}