|
@@ -91,9 +91,16 @@ static long num_allocs = 0;
|
|
|
|
|
|
void *bmalloc(size_t size)
|
|
|
{
|
|
|
+ if (!size) {
|
|
|
+ blog(LOG_ERROR,
|
|
|
+ "bmalloc: Allocating 0 bytes is broken behavior, please "
|
|
|
+ "fix your code! This will crash in future versions of "
|
|
|
+ "OBS.");
|
|
|
+ size = 1;
|
|
|
+ }
|
|
|
+
|
|
|
void *ptr = a_malloc(size);
|
|
|
- if (!ptr && !size)
|
|
|
- ptr = a_malloc(1);
|
|
|
+
|
|
|
if (!ptr) {
|
|
|
os_breakpoint();
|
|
|
bcrash("Out of memory while trying to allocate %lu bytes",
|
|
@@ -109,9 +116,16 @@ void *brealloc(void *ptr, size_t size)
|
|
|
if (!ptr)
|
|
|
os_atomic_inc_long(&num_allocs);
|
|
|
|
|
|
+ if (!size) {
|
|
|
+ blog(LOG_ERROR,
|
|
|
+ "brealloc: Allocating 0 bytes is broken behavior, please "
|
|
|
+ "fix your code! This will crash in future versions of "
|
|
|
+ "OBS.");
|
|
|
+ size = 1;
|
|
|
+ }
|
|
|
+
|
|
|
ptr = a_realloc(ptr, size);
|
|
|
- if (!ptr && !size)
|
|
|
- ptr = a_realloc(ptr, 1);
|
|
|
+
|
|
|
if (!ptr) {
|
|
|
os_breakpoint();
|
|
|
bcrash("Out of memory while trying to allocate %lu bytes",
|