aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/memory.cpp')
-rw-r--r--src/memory.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/memory.cpp b/src/memory.cpp
index 98a2ac0..e989210 100644
--- a/src/memory.cpp
+++ b/src/memory.cpp
@@ -81,7 +81,8 @@ malloc(size_t size)
libc_malloc = (malloc_cb)dlsym(RTLD_NEXT, "malloc");
ret = libc_malloc(size);
- memory_usage += malloc_usable_size(ret);
+ if (G_LIKELY(ret))
+ memory_usage += malloc_usable_size(ret);
return ret;
}
@@ -98,7 +99,8 @@ realloc(void *ptr, size_t size)
if (ptr)
memory_usage -= malloc_usable_size(ptr);
ptr = libc_realloc(ptr, size);
- memory_usage += malloc_usable_size(ptr);
+ if (G_LIKELY(ptr))
+ memory_usage += malloc_usable_size(ptr);
return ptr;
}