mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
remove malloc for unused
This commit is contained in:
parent
a1e35b6e13
commit
2fc8e40734
@ -11,8 +11,8 @@ typedef struct PoolArena {
|
|||||||
int block_size;
|
int block_size;
|
||||||
int block_count;
|
int block_count;
|
||||||
int unused_length;
|
int unused_length;
|
||||||
int* unused;
|
|
||||||
char data[kPoolArenaSize];
|
char data[kPoolArenaSize];
|
||||||
|
int unused[];
|
||||||
} PoolArena;
|
} PoolArena;
|
||||||
|
|
||||||
typedef struct Pool {
|
typedef struct Pool {
|
||||||
|
@ -16,7 +16,6 @@ static PoolArena* PoolArena__new(int block_size) {
|
|||||||
self->block_size = block_size;
|
self->block_size = block_size;
|
||||||
self->block_count = block_count;
|
self->block_count = block_count;
|
||||||
self->unused_length = block_count;
|
self->unused_length = block_count;
|
||||||
self->unused = PK_MALLOC(sizeof(int) * block_count);
|
|
||||||
for(int i = 0; i < block_count; i++) {
|
for(int i = 0; i < block_count; i++) {
|
||||||
self->unused[i] = i;
|
self->unused[i] = i;
|
||||||
}
|
}
|
||||||
@ -29,7 +28,6 @@ static void PoolArena__delete(PoolArena* self) {
|
|||||||
PyObject* obj = (PyObject*)(self->data + i * self->block_size);
|
PyObject* obj = (PyObject*)(self->data + i * self->block_size);
|
||||||
if(obj->type != 0) PyObject__dtor(obj);
|
if(obj->type != 0) PyObject__dtor(obj);
|
||||||
}
|
}
|
||||||
PK_FREE(self->unused);
|
|
||||||
PK_FREE(self);
|
PK_FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user