code: updated librg + zpl dependencies
parent
599621fdd8
commit
c74c1efe7c
|
@ -2213,6 +2213,7 @@ LIBRG_API int8_t librg_world_destroy(librg_world *world);
|
|||
LIBRG_API int8_t librg_world_valid(librg_world *world);
|
||||
LIBRG_API int8_t librg_world_userdata_set(librg_world *world, void *data);
|
||||
LIBRG_API void * librg_world_userdata_get(librg_world *world);
|
||||
LIBRG_API int64_t librg_world_entities_tracked();
|
||||
|
||||
// =======================================================================//
|
||||
// !
|
||||
|
@ -2291,13 +2292,15 @@ LIBRG_API int8_t librg_entity_dimension_set(librg_world *world, int64_t e
|
|||
LIBRG_API int32_t librg_entity_dimension_get(librg_world *world, int64_t entity_id);
|
||||
LIBRG_API int8_t librg_entity_owner_set(librg_world *world, int64_t entity_id, int64_t owner_id);
|
||||
LIBRG_API int64_t librg_entity_owner_get(librg_world *world, int64_t entity_id);
|
||||
LIBRG_API int8_t librg_entity_radius_set(librg_world *world, int64_t entity_id, int8_t observed_chunk_radius);
|
||||
LIBRG_API int8_t librg_entity_radius_get(librg_world *world, int64_t entity_id);
|
||||
LIBRG_API int8_t librg_entity_visibility_global_set(librg_world *world, int64_t entity_id, librg_visibility value);
|
||||
LIBRG_API int8_t librg_entity_visibility_global_get(librg_world *world, int64_t entity_id);
|
||||
LIBRG_API int8_t librg_entity_visibility_owner_set(librg_world *world, int64_t entity_id, int64_t owner_id, librg_visibility value);
|
||||
LIBRG_API int8_t librg_entity_visibility_owner_get(librg_world *world, int64_t entity_id, int64_t owner_id);
|
||||
|
||||
/* deprecated since 7.0 */
|
||||
LIBRG_API int8_t librg_entity_radius_set(librg_world *world, int64_t entity_id, int8_t observed_chunk_radius);
|
||||
LIBRG_API int8_t librg_entity_radius_get(librg_world *world, int64_t entity_id);
|
||||
|
||||
#if 0 /* for future releases */
|
||||
LIBRG_API int8_t librg_entity_behavior_set(librg_world *world, int64_t entity_id, librg_behavior key, int32_t value);
|
||||
LIBRG_API int32_t librg_entity_behavior_get(librg_world *world, int64_t entity_id, librg_behavior key);
|
||||
|
@ -2390,6 +2393,8 @@ LIBRG_END_C_DECLS
|
|||
https://github.com/zpl-c/zpl
|
||||
|
||||
Version History:
|
||||
18.1.0 - added table _clear method
|
||||
18.0.4 - fix memory arena alignment & added tests
|
||||
18.0.3 - fix emscripten support
|
||||
18.0.2 - fix global-buffer-overflow in print module
|
||||
- raise ZPL_PRINTF_MAXLEN to 64kb
|
||||
|
@ -2759,8 +2764,8 @@ LIBRG_END_C_DECLS
|
|||
#define ZPL_H
|
||||
|
||||
#define ZPL_VERSION_MAJOR 18
|
||||
#define ZPL_VERSION_MINOR 0
|
||||
#define ZPL_VERSION_PATCH 3
|
||||
#define ZPL_VERSION_MINOR 1
|
||||
#define ZPL_VERSION_PATCH 1
|
||||
#define ZPL_VERSION_PRE ""
|
||||
|
||||
// file: zpl_hedley.h
|
||||
|
@ -6641,10 +6646,18 @@ LIBRG_END_C_DECLS
|
|||
zpl_isize entry_index;
|
||||
} zpl_hash_table_find_result;
|
||||
|
||||
/**
|
||||
* Combined macro for a quick delcaration + definition
|
||||
*/
|
||||
|
||||
#define ZPL_TABLE(PREFIX, NAME, FUNC, VALUE) \
|
||||
ZPL_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE); \
|
||||
ZPL_TABLE_DEFINE(NAME, FUNC, VALUE);
|
||||
|
||||
/**
|
||||
* Table delcaration macro that generates the interface
|
||||
*/
|
||||
|
||||
#define ZPL_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE) \
|
||||
typedef struct ZPL_JOIN2(NAME, Entry) { \
|
||||
zpl_u64 key; \
|
||||
|
@ -6659,6 +6672,7 @@ LIBRG_END_C_DECLS
|
|||
\
|
||||
PREFIX void ZPL_JOIN2(FUNC, init) (NAME *h, zpl_allocator a); \
|
||||
PREFIX void ZPL_JOIN2(FUNC, destroy) (NAME *h); \
|
||||
PREFIX void ZPL_JOIN2(FUNC, clear) (NAME *h); \
|
||||
PREFIX VALUE *ZPL_JOIN2(FUNC, get) (NAME *h, zpl_u64 key); \
|
||||
PREFIX zpl_isize ZPL_JOIN2(FUNC, slot) (NAME *h, zpl_u64 key); \
|
||||
PREFIX void ZPL_JOIN2(FUNC, set) (NAME *h, zpl_u64 key, VALUE value); \
|
||||
|
@ -6670,6 +6684,10 @@ LIBRG_END_C_DECLS
|
|||
PREFIX void ZPL_JOIN2(FUNC, remove) (NAME *h, zpl_u64 key); \
|
||||
PREFIX void ZPL_JOIN2(FUNC, remove_entry) (NAME *h, zpl_isize idx);
|
||||
|
||||
/**
|
||||
* Table definition interfaces that generates the implementation
|
||||
*/
|
||||
|
||||
#define ZPL_TABLE_DEFINE(NAME, FUNC, VALUE) \
|
||||
void ZPL_JOIN2(FUNC, init)(NAME * h, zpl_allocator a) { \
|
||||
zpl_array_init(h->hashes, a); \
|
||||
|
@ -6681,6 +6699,11 @@ LIBRG_END_C_DECLS
|
|||
if (h->hashes) zpl_array_free(h->hashes); \
|
||||
} \
|
||||
\
|
||||
void ZPL_JOIN2(FUNC, clear)(NAME * h) { \
|
||||
for (int i = 0; i < zpl_array_count(h->hashes); i++) h->hashes[i] = -1; \
|
||||
zpl_array_clear(h->entries); \
|
||||
} \
|
||||
\
|
||||
zpl_isize ZPL_JOIN2(FUNC, slot)(NAME * h, zpl_u64 key) { \
|
||||
for (zpl_isize i = 0; i < zpl_array_count(h->entries); i++) { \
|
||||
if (h->entries[i].key == key) { \
|
||||
|
@ -6790,6 +6813,7 @@ LIBRG_END_C_DECLS
|
|||
map_proc(h->entries[i].key, h->entries[i].value); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
void ZPL_JOIN2(FUNC, map_mut)(NAME * h, void (*map_proc)(zpl_u64 key, VALUE * value)) { \
|
||||
ZPL_ASSERT_NOT_NULL(h); \
|
||||
ZPL_ASSERT_NOT_NULL(map_proc); \
|
||||
|
@ -6815,7 +6839,7 @@ LIBRG_END_C_DECLS
|
|||
} \
|
||||
h->entries[index].value = value; \
|
||||
if (ZPL_JOIN2(FUNC, _full)(h)) ZPL_JOIN2(FUNC, grow)(h); \
|
||||
}\
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
|
@ -10825,11 +10849,11 @@ LIBRG_END_C_DECLS
|
|||
switch (type) {
|
||||
case ZPL_ALLOCATION_ALLOC: {
|
||||
void *end = zpl_pointer_add(arena->physical_start, arena->total_allocated);
|
||||
zpl_isize total_size = size + alignment;
|
||||
zpl_isize total_size = zpl_align_forward_i64(size, alignment);
|
||||
|
||||
// NOTE: Out of memory
|
||||
if (arena->total_allocated + total_size > cast(zpl_isize) arena->total_size) {
|
||||
zpl__printf_err("%s", "Arena out of memory\n");
|
||||
// zpl__printf_err("%s", "Arena out of memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -20730,6 +20754,11 @@ typedef struct librg_event_t {
|
|||
void * userdata; /* userpointer that is passed from librg_world_write/librg_world_read fns */
|
||||
} librg_event_t;
|
||||
|
||||
typedef struct librg_owner_entity_pair_t {
|
||||
int64_t owner_id; /* id of the owner who this event is called for */
|
||||
int64_t entity_id; /* id of an entity which this event is called about */
|
||||
} librg_owner_entity_pair_t;
|
||||
|
||||
typedef struct librg_world_t {
|
||||
uint8_t valid;
|
||||
zpl_allocator allocator;
|
||||
|
@ -20743,6 +20772,12 @@ typedef struct librg_world_t {
|
|||
librg_table_ent entity_map;
|
||||
librg_table_tbl owner_map;
|
||||
|
||||
librg_table_tbl dimensions;
|
||||
|
||||
/* owner-entity pair, needed for more effective query */
|
||||
/* achieved by caching only owned entities and reducing the first iteration cycle */
|
||||
zpl_array(librg_owner_entity_pair_t) owner_entity_pairs;
|
||||
|
||||
void *userdata;
|
||||
} librg_world_t;
|
||||
|
||||
|
@ -20815,6 +20850,9 @@ librg_world *librg_world_create() {
|
|||
librg_table_ent_init(&wld->entity_map, wld->allocator);
|
||||
librg_table_tbl_init(&wld->owner_map, wld->allocator);
|
||||
zpl_random_init(&wld->random);
|
||||
zpl_array_init(wld->owner_entity_pairs, wld->allocator);
|
||||
|
||||
librg_table_tbl_init(&wld->dimensions, wld->allocator);
|
||||
|
||||
return (librg_world *)wld;
|
||||
}
|
||||
|
@ -20843,6 +20881,9 @@ int8_t librg_world_destroy(librg_world *world) {
|
|||
librg_table_tbl_destroy(&wld->owner_map);
|
||||
}
|
||||
|
||||
zpl_array_free(wld->owner_entity_pairs);
|
||||
librg_table_tbl_destroy(&wld->dimensions);
|
||||
|
||||
/* mark it invalid */
|
||||
wld->valid = LIBRG_FALSE;
|
||||
|
||||
|
@ -20869,6 +20910,12 @@ void *librg_world_userdata_get(librg_world *world) {
|
|||
return wld->userdata;
|
||||
}
|
||||
|
||||
int64_t librg_world_entities_tracked(librg_world *world) {
|
||||
LIBRG_ASSERT(world); if (!world) return LIBRG_WORLD_INVALID;
|
||||
librg_world_t *wld = (librg_world_t *)world;
|
||||
return zpl_array_count(wld->entity_map.entries);
|
||||
}
|
||||
|
||||
// =======================================================================//
|
||||
// !
|
||||
// ! Runtime configuration
|
||||
|
@ -21138,6 +21185,14 @@ int8_t librg_entity_untrack(librg_world *world, int64_t entity_id) {
|
|||
librg_table_i64_destroy(snapshot);
|
||||
librg_table_tbl_remove(&wld->owner_map, entity->owner_id);
|
||||
}
|
||||
|
||||
/* cleanup owner-entity pair */
|
||||
for (int i = 0; i < zpl_array_count(wld->owner_entity_pairs); ++i) {
|
||||
if (wld->owner_entity_pairs[i].entity_id == entity_id) {
|
||||
zpl_array_remove_at(wld->owner_entity_pairs, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* cleanup owner visibility */
|
||||
|
@ -21215,6 +21270,35 @@ int8_t librg_entity_owner_set(librg_world *world, int64_t entity_id, int64_t own
|
|||
return LIBRG_ENTITY_FOREIGN;
|
||||
}
|
||||
|
||||
/* update owner-entity pairing */
|
||||
if (owner_id != LIBRG_OWNER_INVALID) {
|
||||
bool ownership_pair_found = false;
|
||||
for (int i = 0; i < zpl_array_count(wld->owner_entity_pairs) && !ownership_pair_found; ++i) {
|
||||
if (wld->owner_entity_pairs[i].entity_id == entity_id) {
|
||||
ownership_pair_found = true;
|
||||
|
||||
/* update owner if we found the entity */
|
||||
if (wld->owner_entity_pairs[i].owner_id != owner_id) {
|
||||
wld->owner_entity_pairs[i].owner_id = owner_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ownership_pair_found) {
|
||||
librg_owner_entity_pair_t pair = { owner_id, entity_id };
|
||||
zpl_array_append(wld->owner_entity_pairs, pair);
|
||||
}
|
||||
} else {
|
||||
if (entity->owner_id != LIBRG_OWNER_INVALID) {
|
||||
/* cleanup owner-entity pair */
|
||||
for (int i = 0; i < zpl_array_count(wld->owner_entity_pairs); ++i) {
|
||||
if (wld->owner_entity_pairs[i].entity_id == entity_id) {
|
||||
zpl_array_remove_at(wld->owner_entity_pairs, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entity->owner_id = owner_id;
|
||||
entity->flag_owner_updated = LIBRG_TRUE;
|
||||
|
||||
|
@ -21537,22 +21621,22 @@ int32_t librg_world_query(librg_world *world, int64_t owner_id, uint8_t chunk_ra
|
|||
|
||||
size_t buffer_limit = *entity_amount;
|
||||
size_t total_count = zpl_array_count(wld->entity_map.entries);
|
||||
size_t result_amount = 0;
|
||||
|
||||
librg_table_i64 results = {0};
|
||||
librg_table_tbl dimensions = {0};
|
||||
|
||||
librg_table_i64_init(&results, wld->allocator);
|
||||
librg_table_tbl_init(&dimensions, wld->allocator);
|
||||
/* mini helper for pushing entity */
|
||||
/* if it will overflow do not push, just increase counter for future statistics */
|
||||
#define librg_push_entity(entity_id) \
|
||||
{ if (result_amount + 1 <= buffer_limit) entity_ids[result_amount++] = entity_id; else result_amount++; }
|
||||
|
||||
/* generate a map of visible chunks (only counting owned entities) */
|
||||
for (size_t i=0; i < total_count; ++i) {
|
||||
uint64_t entity_id = wld->entity_map.entries[i].key;
|
||||
librg_entity_t *entity = &wld->entity_map.entries[i].value;
|
||||
for (int i = 0; i < zpl_array_count(wld->owner_entity_pairs); ++i) {
|
||||
if (wld->owner_entity_pairs[i].owner_id != owner_id) continue;
|
||||
|
||||
uint64_t entity_id = wld->owner_entity_pairs[i].entity_id;
|
||||
librg_entity_t *entity = librg_table_ent_get(&wld->entity_map, entity_id);
|
||||
|
||||
/* allways add self-owned entities */
|
||||
if (entity->owner_id == owner_id) {
|
||||
librg_table_i64_set(&results, entity_id, 1);
|
||||
}
|
||||
librg_push_entity(entity_id);
|
||||
|
||||
/* immidiately skip, if entity was not placed correctly */
|
||||
if (entity->chunks[0] == LIBRG_CHUNK_INVALID) continue;
|
||||
|
@ -21560,12 +21644,12 @@ int32_t librg_world_query(librg_world *world, int64_t owner_id, uint8_t chunk_ra
|
|||
if (entity->owner_id != owner_id) continue;
|
||||
|
||||
/* fetch, or create chunk set in this dimension if does not exist */
|
||||
librg_table_i64 *dim_chunks = librg_table_tbl_get(&dimensions, entity->dimension);
|
||||
librg_table_i64 *dim_chunks = librg_table_tbl_get(&wld->dimensions, entity->dimension);
|
||||
|
||||
if (!dim_chunks) {
|
||||
librg_table_i64 _chunks = {0};
|
||||
librg_table_tbl_set(&dimensions, entity->dimension, _chunks);
|
||||
dim_chunks = librg_table_tbl_get(&dimensions, entity->dimension);
|
||||
librg_table_tbl_set(&wld->dimensions, entity->dimension, _chunks);
|
||||
dim_chunks = librg_table_tbl_get(&wld->dimensions, entity->dimension);
|
||||
librg_table_i64_init(dim_chunks, wld->allocator);
|
||||
}
|
||||
|
||||
|
@ -21579,16 +21663,13 @@ int32_t librg_world_query(librg_world *world, int64_t owner_id, uint8_t chunk_ra
|
|||
}
|
||||
}
|
||||
|
||||
/* a slightly increased buffer_limit, that includes own entities */
|
||||
/* that allows us to prevent edge-cases where the code below will include our entities in the result as well */
|
||||
size_t owned_entities = zpl_array_count(results.entries);
|
||||
size_t buffer_limit_extended = buffer_limit + owned_entities;
|
||||
|
||||
/* iterate on all entities, and check if they are inside of the interested chunks */
|
||||
for (size_t i=0; i < LIBRG_MIN(buffer_limit_extended, total_count); ++i) {
|
||||
for (size_t i=0; i < total_count; ++i) {
|
||||
uint64_t entity_id = wld->entity_map.entries[i].key;
|
||||
librg_entity_t *entity = &wld->entity_map.entries[i].value;
|
||||
librg_table_i64 *chunks = librg_table_tbl_get(&dimensions, entity->dimension);
|
||||
librg_table_i64 *chunks = librg_table_tbl_get(&wld->dimensions, entity->dimension);
|
||||
|
||||
if (entity->owner_id == owner_id) continue;
|
||||
|
||||
/* owner visibility (personal)*/
|
||||
int8_t vis_owner = librg_entity_visibility_owner_get(world, entity_id, owner_id);
|
||||
|
@ -21596,7 +21677,7 @@ int32_t librg_world_query(librg_world *world, int64_t owner_id, uint8_t chunk_ra
|
|||
continue; /* prevent from being included */
|
||||
}
|
||||
else if (vis_owner == LIBRG_VISIBLITY_ALWAYS) {
|
||||
librg_table_i64_set(&results, entity_id, 1); /* always included */
|
||||
librg_push_entity(entity_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -21606,7 +21687,7 @@ int32_t librg_world_query(librg_world *world, int64_t owner_id, uint8_t chunk_ra
|
|||
continue; /* prevent from being included */
|
||||
}
|
||||
else if (vis_global == LIBRG_VISIBLITY_ALWAYS) {
|
||||
librg_table_i64_set(&results, entity_id, 1); /* always included */
|
||||
librg_push_entity(entity_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -21623,27 +21704,23 @@ int32_t librg_world_query(librg_world *world, int64_t owner_id, uint8_t chunk_ra
|
|||
|
||||
/* add entity and continue to the next one */
|
||||
if (entity->chunks[j] == chunk) {
|
||||
librg_table_i64_set(&results, entity_id, 1);
|
||||
librg_push_entity(entity_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* copy/transform results to a plain array */
|
||||
size_t count = zpl_array_count(results.entries);
|
||||
for (size_t i = 0; i < LIBRG_MIN(buffer_limit, count); ++i)
|
||||
entity_ids[i] = results.entries[i].key;
|
||||
|
||||
/* free up temp data */
|
||||
for (int i = 0; i < zpl_array_count(dimensions.entries); ++i)
|
||||
librg_table_i64_destroy(&dimensions.entries[i].value);
|
||||
for (int i = 0; i < zpl_array_count(wld->dimensions.entries); ++i)
|
||||
librg_table_i64_destroy(&wld->dimensions.entries[i].value);
|
||||
|
||||
librg_table_tbl_destroy(&dimensions);
|
||||
librg_table_i64_destroy(&results);
|
||||
librg_table_tbl_clear(&wld->dimensions);
|
||||
|
||||
*entity_amount = LIBRG_MIN(buffer_limit, count);
|
||||
return LIBRG_MAX(0, (int32_t)(count - buffer_limit));
|
||||
#undef librg_push_entity
|
||||
|
||||
*entity_amount = LIBRG_MIN(buffer_limit, result_amount);
|
||||
return LIBRG_MAX(0, (int32_t)(result_amount - buffer_limit));
|
||||
}
|
||||
|
||||
LIBRG_END_C_DECLS
|
||||
|
@ -22001,3 +22078,4 @@ LIBRG_END_C_DECLS
|
|||
#endif // LIBRG_IMPLEMENTATION
|
||||
|
||||
#endif // LIBRG_H
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ GitHub:
|
|||
https://github.com/zpl-c/zpl
|
||||
|
||||
Version History:
|
||||
18.1.0 - added table _clear method
|
||||
18.0.4 - fix memory arena alignment & added tests
|
||||
18.0.3 - fix emscripten support
|
||||
18.0.2 - fix global-buffer-overflow in print module
|
||||
- raise ZPL_PRINTF_MAXLEN to 64kb
|
||||
|
@ -403,8 +405,8 @@ License:
|
|||
#define ZPL_H
|
||||
|
||||
#define ZPL_VERSION_MAJOR 18
|
||||
#define ZPL_VERSION_MINOR 0
|
||||
#define ZPL_VERSION_PATCH 3
|
||||
#define ZPL_VERSION_MINOR 1
|
||||
#define ZPL_VERSION_PATCH 1
|
||||
#define ZPL_VERSION_PRE ""
|
||||
|
||||
// file: zpl_hedley.h
|
||||
|
@ -4285,10 +4287,18 @@ License:
|
|||
zpl_isize entry_index;
|
||||
} zpl_hash_table_find_result;
|
||||
|
||||
/**
|
||||
* Combined macro for a quick delcaration + definition
|
||||
*/
|
||||
|
||||
#define ZPL_TABLE(PREFIX, NAME, FUNC, VALUE) \
|
||||
ZPL_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE); \
|
||||
ZPL_TABLE_DEFINE(NAME, FUNC, VALUE);
|
||||
|
||||
/**
|
||||
* Table delcaration macro that generates the interface
|
||||
*/
|
||||
|
||||
#define ZPL_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE) \
|
||||
typedef struct ZPL_JOIN2(NAME, Entry) { \
|
||||
zpl_u64 key; \
|
||||
|
@ -4303,6 +4313,7 @@ License:
|
|||
\
|
||||
PREFIX void ZPL_JOIN2(FUNC, init) (NAME *h, zpl_allocator a); \
|
||||
PREFIX void ZPL_JOIN2(FUNC, destroy) (NAME *h); \
|
||||
PREFIX void ZPL_JOIN2(FUNC, clear) (NAME *h); \
|
||||
PREFIX VALUE *ZPL_JOIN2(FUNC, get) (NAME *h, zpl_u64 key); \
|
||||
PREFIX zpl_isize ZPL_JOIN2(FUNC, slot) (NAME *h, zpl_u64 key); \
|
||||
PREFIX void ZPL_JOIN2(FUNC, set) (NAME *h, zpl_u64 key, VALUE value); \
|
||||
|
@ -4314,6 +4325,10 @@ License:
|
|||
PREFIX void ZPL_JOIN2(FUNC, remove) (NAME *h, zpl_u64 key); \
|
||||
PREFIX void ZPL_JOIN2(FUNC, remove_entry) (NAME *h, zpl_isize idx);
|
||||
|
||||
/**
|
||||
* Table definition interfaces that generates the implementation
|
||||
*/
|
||||
|
||||
#define ZPL_TABLE_DEFINE(NAME, FUNC, VALUE) \
|
||||
void ZPL_JOIN2(FUNC, init)(NAME * h, zpl_allocator a) { \
|
||||
zpl_array_init(h->hashes, a); \
|
||||
|
@ -4325,6 +4340,11 @@ License:
|
|||
if (h->hashes) zpl_array_free(h->hashes); \
|
||||
} \
|
||||
\
|
||||
void ZPL_JOIN2(FUNC, clear)(NAME * h) { \
|
||||
for (int i = 0; i < zpl_array_count(h->hashes); i++) h->hashes[i] = -1; \
|
||||
zpl_array_clear(h->entries); \
|
||||
} \
|
||||
\
|
||||
zpl_isize ZPL_JOIN2(FUNC, slot)(NAME * h, zpl_u64 key) { \
|
||||
for (zpl_isize i = 0; i < zpl_array_count(h->entries); i++) { \
|
||||
if (h->entries[i].key == key) { \
|
||||
|
@ -4434,6 +4454,7 @@ License:
|
|||
map_proc(h->entries[i].key, h->entries[i].value); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
void ZPL_JOIN2(FUNC, map_mut)(NAME * h, void (*map_proc)(zpl_u64 key, VALUE * value)) { \
|
||||
ZPL_ASSERT_NOT_NULL(h); \
|
||||
ZPL_ASSERT_NOT_NULL(map_proc); \
|
||||
|
@ -4459,7 +4480,7 @@ License:
|
|||
} \
|
||||
h->entries[index].value = value; \
|
||||
if (ZPL_JOIN2(FUNC, _full)(h)) ZPL_JOIN2(FUNC, grow)(h); \
|
||||
}\
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
|
@ -8469,11 +8490,11 @@ License:
|
|||
switch (type) {
|
||||
case ZPL_ALLOCATION_ALLOC: {
|
||||
void *end = zpl_pointer_add(arena->physical_start, arena->total_allocated);
|
||||
zpl_isize total_size = size + alignment;
|
||||
zpl_isize total_size = zpl_align_forward_i64(size, alignment);
|
||||
|
||||
// NOTE: Out of memory
|
||||
if (arena->total_allocated + total_size > cast(zpl_isize) arena->total_size) {
|
||||
zpl__printf_err("%s", "Arena out of memory\n");
|
||||
// zpl__printf_err("%s", "Arena out of memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue