This repository has been archived on 2022-05-21. You can view files and clone it, but cannot push or open issues or pull requests.
LEFTONE/core/loground/pool.c

40 lines
841 B
C
Raw Permalink Normal View History

#include "./pool.h"
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <msgpack.h>
#include "util/memory/memory.h"
#include "core/locommon/counter.h"
#include "core/loentity/pool.h"
#include "core/loshader/ground.h"
#include "./base.h"
LOENTITY_POOL_SOURCE_TEMPLATE(loground)
loground_pool_t* loground_pool_new(
loshader_ground_drawer_t* drawer,
locommon_counter_t* idgen,
size_t length) {
assert(drawer != NULL);
assert(idgen != NULL);
assert(length > 0);
loground_pool_t* pool = memory_new(
sizeof(*pool) + (length-1)*sizeof(pool->items[0]));
*pool = (typeof(*pool)) {
.idgen = idgen,
.length = length,
};
for (size_t i = 0; i < pool->length; ++i) {
loground_base_initialize(&pool->items[i], drawer);
}
return pool;
}