mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-23 13:00:17 +00:00
Compare commits
No commits in common. "85a593222e52b66148bc2eaaec0d20ebaddb45e4" and "a1e35b6e136f8edef10c6ad16d5e0f2921a3d6da" have entirely different histories.
85a593222e
...
a1e35b6e13
@ -47,33 +47,23 @@ file(GLOB_RECURSE POCKETPY_SRC ${CMAKE_CURRENT_LIST_DIR}/src/*.c)
|
|||||||
|
|
||||||
if(PK_ENABLE_OS)
|
if(PK_ENABLE_OS)
|
||||||
add_definitions(-DPK_ENABLE_OS=1)
|
add_definitions(-DPK_ENABLE_OS=1)
|
||||||
else()
|
|
||||||
add_definitions(-DPK_ENABLE_OS=0)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PK_ENABLE_THREADS)
|
if(PK_ENABLE_THREADS)
|
||||||
add_definitions(-DPK_ENABLE_THREADS=1)
|
add_definitions(-DPK_ENABLE_THREADS=1)
|
||||||
else()
|
|
||||||
add_definitions(-DPK_ENABLE_THREADS=0)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PK_ENABLE_DETERMINISM)
|
if(PK_ENABLE_DETERMINISM)
|
||||||
add_subdirectory(3rd/dmath/dmath)
|
add_subdirectory(3rd/dmath/dmath)
|
||||||
add_definitions(-DPK_ENABLE_DETERMINISM=1)
|
add_definitions(-DPK_ENABLE_DETERMINISM=1)
|
||||||
else()
|
|
||||||
add_definitions(-DPK_ENABLE_DETERMINISM=0)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PK_ENABLE_WATCHDOG)
|
if(PK_ENABLE_WATCHDOG)
|
||||||
add_definitions(-DPK_ENABLE_WATCHDOG=1)
|
add_definitions(-DPK_ENABLE_WATCHDOG=1)
|
||||||
else()
|
|
||||||
add_definitions(-DPK_ENABLE_WATCHDOG=0)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PK_ENABLE_CUSTOM_SNAME)
|
if(PK_ENABLE_CUSTOM_SNAME)
|
||||||
add_definitions(-DPK_ENABLE_CUSTOM_SNAME=1)
|
add_definitions(-DPK_ENABLE_CUSTOM_SNAME=1)
|
||||||
else()
|
|
||||||
add_definitions(-DPK_ENABLE_CUSTOM_SNAME=0)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,6 +16,7 @@ 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;
|
||||||
}
|
}
|
||||||
@ -28,6 +29,7 @@ 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