From 2fc8e407346f935fa35488b057ace70db29b81d2 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 30 Jun 2025 14:04:15 +0800 Subject: [PATCH] remove malloc for unused --- include/pocketpy/interpreter/objectpool.h | 2 +- src/interpreter/objectpool.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/pocketpy/interpreter/objectpool.h b/include/pocketpy/interpreter/objectpool.h index c9700583..71b29f7a 100644 --- a/include/pocketpy/interpreter/objectpool.h +++ b/include/pocketpy/interpreter/objectpool.h @@ -11,8 +11,8 @@ typedef struct PoolArena { int block_size; int block_count; int unused_length; - int* unused; char data[kPoolArenaSize]; + int unused[]; } PoolArena; typedef struct Pool { diff --git a/src/interpreter/objectpool.c b/src/interpreter/objectpool.c index fb9685ca..b8c5786e 100644 --- a/src/interpreter/objectpool.c +++ b/src/interpreter/objectpool.c @@ -16,7 +16,6 @@ static PoolArena* PoolArena__new(int block_size) { self->block_size = block_size; self->block_count = block_count; self->unused_length = block_count; - self->unused = PK_MALLOC(sizeof(int) * block_count); for(int i = 0; i < block_count; i++) { self->unused[i] = i; } @@ -29,7 +28,6 @@ static void PoolArena__delete(PoolArena* self) { PyObject* obj = (PyObject*)(self->data + i * self->block_size); if(obj->type != 0) PyObject__dtor(obj); } - PK_FREE(self->unused); PK_FREE(self); }