This commit is contained in:
nub31
2025-10-26 20:04:57 +01:00
parent d11df414ad
commit 27bc4da4fd
3 changed files with 11 additions and 8 deletions

View File

@@ -12,7 +12,7 @@ void *rc_alloc(size_t size, void (*destructor)(void *self))
exit(69);
}
header->ref_count = 0;
header->ref_count = 1;
header->destructor = destructor;
return (void *)(header + 1);
@@ -29,7 +29,7 @@ void rc_release(void *obj)
{
ref_header *header = ((ref_header *)obj) - 1;
printf("rc_release\n");
if (--header->ref_count <= 0)
if (--header->ref_count == 0)
{
if (header->destructor)
{