This commit is contained in:
jeka committed 2026-03-06 01:36:57 +03:00
1 parent b2640e7201
commit 15c7968c8c
34 files changed
+332 -284

No files matched your search

+6 -5
View File
@@ -2,10 +2,11 @@
#include "memory_pool.h"
#include <stdlib.h>
#include <string.h>
#include "mem.h"
// Инициализировать пул памяти
struct memory_pool* memory_pool_init(size_t object_size) {
struct memory_pool* pool = calloc(1, sizeof(struct memory_pool));
struct memory_pool* pool = u_calloc(1, sizeof(struct memory_pool));
if (!pool) {
return NULL;
}
@@ -33,7 +34,7 @@ void* memory_pool_alloc(struct memory_pool* pool) {
}
pool->allocations++;
return calloc(1, pool->object_size); // Используем calloc для инициализации нулями
return u_calloc(1, pool->object_size); // Используем calloc для инициализации нулями
}
// Освободить объект в пул или в free
@@ -51,7 +52,7 @@ void memory_pool_free(struct memory_pool* pool, void* obj) {
}
// Иначе освободить через free
free(obj);
u_free(obj);
}
// Получить статистику пула
@@ -77,11 +78,11 @@ void memory_pool_destroy(struct memory_pool* pool) {
void* obj = pool->free_head;
while (obj) {
void* next = *(void**)obj;
free(obj);
u_free(obj);
obj = next;
}
pool->free_head = NULL;
pool->free_count = 0;
free(pool);
u_free(pool);
}