blueloveTH преди 1 година
родител
ревизия
026171e753
променени са 1 файла, в които са добавени 6 реда и са изтрити 1 реда
  1. 6 1
      include/pocketpy/common/refcount.h

+ 6 - 1
include/pocketpy/common/refcount.h

@@ -11,7 +11,12 @@ typedef struct RefCounted {
 } RefCounted;
 } RefCounted;
 
 
 #define PK_INCREF(obj) (obj)->rc.count++
 #define PK_INCREF(obj) (obj)->rc.count++
-#define PK_DECREF(obj) if (--(obj)->rc.count == 0) (obj)->rc.dtor(obj)
+#define PK_DECREF(obj) do { \
+    if(--(obj)->rc.count == 0) { \
+        (obj)->rc.dtor(obj); \
+        free(obj); \
+    } \
+} while(0)
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }