libobs/util: Breakpoint crash on "out of memory"
This forces proper crash handling to generate a stack trace.master
parent
fa5c477826
commit
52d5a9b0b4
|
@ -18,6 +18,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "base.h"
|
#include "base.h"
|
||||||
#include "bmem.h"
|
#include "bmem.h"
|
||||||
|
#include "platform.h"
|
||||||
#include "threading.h"
|
#include "threading.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -97,9 +98,11 @@ void *bmalloc(size_t size)
|
||||||
void *ptr = alloc.malloc(size);
|
void *ptr = alloc.malloc(size);
|
||||||
if (!ptr && !size)
|
if (!ptr && !size)
|
||||||
ptr = alloc.malloc(1);
|
ptr = alloc.malloc(1);
|
||||||
if (!ptr)
|
if (!ptr) {
|
||||||
|
os_breakpoint();
|
||||||
bcrash("Out of memory while trying to allocate %lu bytes",
|
bcrash("Out of memory while trying to allocate %lu bytes",
|
||||||
(unsigned long)size);
|
(unsigned long)size);
|
||||||
|
}
|
||||||
|
|
||||||
os_atomic_inc_long(&num_allocs);
|
os_atomic_inc_long(&num_allocs);
|
||||||
return ptr;
|
return ptr;
|
||||||
|
@ -113,9 +116,11 @@ void *brealloc(void *ptr, size_t size)
|
||||||
ptr = alloc.realloc(ptr, size);
|
ptr = alloc.realloc(ptr, size);
|
||||||
if (!ptr && !size)
|
if (!ptr && !size)
|
||||||
ptr = alloc.realloc(ptr, 1);
|
ptr = alloc.realloc(ptr, 1);
|
||||||
if (!ptr)
|
if (!ptr) {
|
||||||
|
os_breakpoint();
|
||||||
bcrash("Out of memory while trying to allocate %lu bytes",
|
bcrash("Out of memory while trying to allocate %lu bytes",
|
||||||
(unsigned long)size);
|
(unsigned long)size);
|
||||||
|
}
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue