浏览代码

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

This forces proper crash handling to generate a stack trace.
jp9000 10 年之前
父节点
当前提交
52d5a9b0b4
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      libobs/util/bmem.c

+ 7 - 2
libobs/util/bmem.c

@@ -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;
 }