mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-24 23:31:36 +08:00
libobs/util: Breakpoint crash on "out of memory"
This forces proper crash handling to generate a stack trace.
This commit is contained in:
+7
-2
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user