fix rc leak

This commit is contained in:
blueloveTH 2024-06-17 12:18:28 +08:00
parent 3a257aefb1
commit 026171e753

View File

@ -11,7 +11,12 @@ typedef struct RefCounted {
} RefCounted;
#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
}