Explorar o código

fix alloc/free cnt

ithewei %!s(int64=2) %!d(string=hai) anos
pai
achega
b9500cc6c5
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      base/hbase.c

+ 1 - 1
base/hbase.c

@@ -33,7 +33,7 @@ void* hv_malloc(size_t size) {
 
 void* hv_realloc(void* oldptr, size_t newsize, size_t oldsize) {
     hatomic_inc(&s_alloc_cnt);
-    hatomic_inc(&s_free_cnt);
+    if (oldptr) hatomic_inc(&s_free_cnt);
     void* ptr = realloc(oldptr, newsize);
     if (!ptr) {
         fprintf(stderr, "realloc failed!\n");