Made the code compile without libRR
The redundancy-reduction library (libRR), which was used, has now been thrown out in favor of functions from the C standard library.
This commit is contained in:
parent
b2f9aaa021
commit
f98b2371b1
|
@ -0,0 +1 @@
|
||||||
|
Maths
|
|
@ -2,7 +2,7 @@
|
||||||
#ifndef MT_CONTEXT_H
|
#ifndef MT_CONTEXT_H
|
||||||
#define MT_CONTEXT_H
|
#define MT_CONTEXT_H
|
||||||
|
|
||||||
#include <librr/types.h>
|
#include <stdint.h>
|
||||||
#include <shadow-tag.h>
|
#include <shadow-tag.h>
|
||||||
#include <shadow.h>
|
#include <shadow.h>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#ifndef MT_ENTITY_H
|
#ifndef MT_ENTITY_H
|
||||||
#define MT_ENTITY_H
|
#define MT_ENTITY_H
|
||||||
|
|
||||||
#include <librr/types.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct MtEntity MtEntity;
|
typedef struct MtEntity MtEntity;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ struct MtEntity
|
||||||
|
|
||||||
/// @brief: The identifier of the background structure "shadow".
|
/// @brief: The identifier of the background structure "shadow".
|
||||||
/// This is used for resolving this entity to its actual data.
|
/// This is used for resolving this entity to its actual data.
|
||||||
u32_t shadow_id;
|
uint32_t shadow_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MT_ENTITY_H
|
#endif // MT_ENTITY_H
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
#ifndef MT_SHADOW_TAG_H
|
#ifndef MT_SHADOW_TAG_H
|
||||||
#define MT_SHADOW_TAG_H
|
#define MT_SHADOW_TAG_H
|
||||||
|
|
||||||
#include <librr/types.h>
|
#include <stdbool.h>
|
||||||
#include <librr/linear_algebra.h>
|
#include <stdint.h>
|
||||||
|
#include <alphaumlaut/maths.h>
|
||||||
#include <entity.h>
|
#include <entity.h>
|
||||||
|
|
||||||
typedef struct MtShadowTag MtShadowTag;
|
typedef struct MtShadowTag MtShadowTag;
|
||||||
|
@ -34,24 +35,24 @@ struct MtShadowTag
|
||||||
MtShadowTag *next;
|
MtShadowTag *next;
|
||||||
|
|
||||||
MtShadowTagType type;
|
MtShadowTagType type;
|
||||||
u32_t name_identifier;
|
uint32_t name_identifier;
|
||||||
union MtShadowTagData
|
union MtShadowTagData
|
||||||
{
|
{
|
||||||
bool_t boolean;
|
bool boolean;
|
||||||
i64_t integer;
|
int64_t integer;
|
||||||
f64_t decimal;
|
double decimal;
|
||||||
char *string;
|
char *string;
|
||||||
void *raw_pointer;
|
void *raw_pointer;
|
||||||
rr_vec2f_s vec2f;
|
AuVec2f vec2f;
|
||||||
rr_vec3f_s vec3f;
|
AuVec3f vec3f;
|
||||||
rr_vec4f_s vec4f;
|
AuVec4f vec4f;
|
||||||
MtEntity entity;
|
MtEntity entity;
|
||||||
} data;
|
} data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MtShadowTagPool
|
struct MtShadowTagPool
|
||||||
{
|
{
|
||||||
usz_t capacity;
|
uint32_t capacity;
|
||||||
MtShadowTag *allocation;
|
MtShadowTag *allocation;
|
||||||
MtShadowTag *first_free;
|
MtShadowTag *first_free;
|
||||||
MtShadowTagPool *continuation;
|
MtShadowTagPool *continuation;
|
||||||
|
@ -59,8 +60,8 @@ struct MtShadowTagPool
|
||||||
|
|
||||||
struct MtShadowTagNameArena
|
struct MtShadowTagNameArena
|
||||||
{
|
{
|
||||||
usz_t capacity;
|
uint32_t capacity;
|
||||||
usz_t usage;
|
uint32_t usage;
|
||||||
char *allocation;
|
char *allocation;
|
||||||
MtShadowTagNameArena *continuation;
|
MtShadowTagNameArena *continuation;
|
||||||
};
|
};
|
||||||
|
@ -68,15 +69,15 @@ struct MtShadowTagNameArena
|
||||||
struct MtShadowTagName
|
struct MtShadowTagName
|
||||||
{
|
{
|
||||||
char *string_in_arena;
|
char *string_in_arena;
|
||||||
u32_t identifier;
|
uint32_t identifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MtShadowTagNameRegistry
|
struct MtShadowTagNameRegistry
|
||||||
{
|
{
|
||||||
usz_t names_capacity;
|
uint32_t names_capacity;
|
||||||
usz_t num_names;
|
uint32_t num_names;
|
||||||
MtShadowTagName *names;
|
MtShadowTagName *names;
|
||||||
u32_t id_counter;
|
uint32_t id_counter;
|
||||||
|
|
||||||
MtShadowTagNameArena *root_arena;
|
MtShadowTagNameArena *root_arena;
|
||||||
};
|
};
|
||||||
|
@ -90,7 +91,7 @@ struct MtShadowTagSystem
|
||||||
void mt_init_shadow_tag_system(MtShadowTagSystem *tag_system);
|
void mt_init_shadow_tag_system(MtShadowTagSystem *tag_system);
|
||||||
void mt_cleanup_shadow_tag_system(MtShadowTagSystem *tag_system);
|
void mt_cleanup_shadow_tag_system(MtShadowTagSystem *tag_system);
|
||||||
|
|
||||||
MtShadowTagPool * mt_new_shadow_tag_pool(usz_t capacity);
|
MtShadowTagPool * mt_new_shadow_tag_pool(uint32_t capacity);
|
||||||
|
|
||||||
/// @brief Crates a new MtShadowTagPool with a given capacity.
|
/// @brief Crates a new MtShadowTagPool with a given capacity.
|
||||||
/// @warning Don't use `mt_free_shadow_tag_pool()` with use created with this method.
|
/// @warning Don't use `mt_free_shadow_tag_pool()` with use created with this method.
|
||||||
|
@ -98,7 +99,7 @@ MtShadowTagPool * mt_new_shadow_tag_pool(usz_t capacity);
|
||||||
/// @param pool A pointer to the location at which the pool should be created.
|
/// @param pool A pointer to the location at which the pool should be created.
|
||||||
/// @param capacity The number of entity shadow tags which should be able to reside in
|
/// @param capacity The number of entity shadow tags which should be able to reside in
|
||||||
/// the first instance of the pool. The pool will allocate more once needed.
|
/// the first instance of the pool. The pool will allocate more once needed.
|
||||||
void mt_init_shadow_tag_pool(MtShadowTagPool *pool, usz_t capacity);
|
void mt_init_shadow_tag_pool(MtShadowTagPool *pool, uint32_t capacity);
|
||||||
void mt_free_shadow_tag_pool(MtShadowTagPool *pool);
|
void mt_free_shadow_tag_pool(MtShadowTagPool *pool);
|
||||||
|
|
||||||
MtShadowTag * mt_alloc_shadow_tag(void *context_ptr);
|
MtShadowTag * mt_alloc_shadow_tag(void *context_ptr);
|
||||||
|
@ -112,6 +113,6 @@ MtShadowTag * mt_alloc_shadow_tag_in_pool(MtShadowTagPool *pool);
|
||||||
MtShadowTag * mt_alloc_shadow_tag_before(MtShadowTag *chain_start);
|
MtShadowTag * mt_alloc_shadow_tag_before(MtShadowTag *chain_start);
|
||||||
void mt_free_shadow_tag_chain(MtShadowTag *tag);
|
void mt_free_shadow_tag_chain(MtShadowTag *tag);
|
||||||
|
|
||||||
u32_t mt_tag_name_to_id(void *context_ptr, const char *tag_name);
|
uint32_t mt_tag_name_to_id(void *context_ptr, const char *tag_name);
|
||||||
|
|
||||||
#endif // MT_SHADOW_TAG_H
|
#endif // MT_SHADOW_TAG_H
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#ifndef MT_SHADOW_H
|
#ifndef MT_SHADOW_H
|
||||||
#define MT_SHADOW_H
|
#define MT_SHADOW_H
|
||||||
|
|
||||||
#include <librr/types.h>
|
#include <stdint.h>
|
||||||
#include <shadow-tag.h>
|
#include <shadow-tag.h>
|
||||||
|
|
||||||
typedef struct MtShadowRegistry MtShadowRegistry;
|
typedef struct MtShadowRegistry MtShadowRegistry;
|
||||||
|
@ -17,7 +17,7 @@ struct MtShadow
|
||||||
{
|
{
|
||||||
void *context;
|
void *context;
|
||||||
MtShadowTag *tag_chain_start;
|
MtShadowTag *tag_chain_start;
|
||||||
u32_t identifier;
|
uint32_t identifier;
|
||||||
|
|
||||||
MtShadowPool *pool;
|
MtShadowPool *pool;
|
||||||
MtShadow *pool_next;
|
MtShadow *pool_next;
|
||||||
|
@ -25,7 +25,7 @@ struct MtShadow
|
||||||
|
|
||||||
struct MtShadowPool
|
struct MtShadowPool
|
||||||
{
|
{
|
||||||
usz_t capacity;
|
uint32_t capacity;
|
||||||
MtShadow *shadows;
|
MtShadow *shadows;
|
||||||
MtShadow *first_free;
|
MtShadow *first_free;
|
||||||
MtShadowPool *continuation;
|
MtShadowPool *continuation;
|
||||||
|
@ -57,7 +57,7 @@ struct MtShadowRegistry
|
||||||
// to the next free entry, the index representing the ID's value and having
|
// to the next free entry, the index representing the ID's value and having
|
||||||
// stored the next free entry's index. Conceptually similar to the internals
|
// stored the next free entry's index. Conceptually similar to the internals
|
||||||
// of the old File Allocation Table filesystems (FAT12, FAT16, FAT32).
|
// of the old File Allocation Table filesystems (FAT12, FAT16, FAT32).
|
||||||
u32_t id_counter;
|
uint32_t id_counter;
|
||||||
MtShadowPool root_pool;
|
MtShadowPool root_pool;
|
||||||
MtShadowLookupTree lookup_tree;
|
MtShadowLookupTree lookup_tree;
|
||||||
void *context_ptr;
|
void *context_ptr;
|
||||||
|
@ -67,15 +67,15 @@ MtShadowRegistry mt_create_shadow_registry(void *context_ptr);
|
||||||
void mt_cleanup_shadow_registry(MtShadowRegistry *registry);
|
void mt_cleanup_shadow_registry(MtShadowRegistry *registry);
|
||||||
|
|
||||||
MtShadow * mt_create_shadow(MtShadowRegistry *registry);
|
MtShadow * mt_create_shadow(MtShadowRegistry *registry);
|
||||||
MtShadow * mt_lookup_shadow(MtShadowRegistry *registry, u32_t identifier);
|
MtShadow * mt_lookup_shadow(MtShadowRegistry *registry, uint32_t identifier);
|
||||||
void mt_delete_shadow(MtShadowRegistry *registry, MtShadow *shadow);
|
void mt_delete_shadow(MtShadowRegistry *registry, MtShadow *shadow);
|
||||||
|
|
||||||
void mt_cleanup_shadow_pool(MtShadowPool *pool);
|
void mt_cleanup_shadow_pool(MtShadowPool *pool);
|
||||||
void mt_free_shadow_pool(MtShadowPool *pool);
|
void mt_free_shadow_pool(MtShadowPool *pool);
|
||||||
MtShadowLookupTree mt_create_shadow_lookup_tree();
|
MtShadowLookupTree mt_create_shadow_lookup_tree();
|
||||||
|
|
||||||
void mt_init_shadow_pool(MtShadowPool *pool, usz_t capacity);
|
void mt_init_shadow_pool(MtShadowPool *pool, uint32_t capacity);
|
||||||
MtShadowPool * mt_new_shadow_pool(usz_t capacity);
|
MtShadowPool * mt_new_shadow_pool(uint32_t capacity);
|
||||||
MtShadow * mt_pool_shadow(MtShadowPool *pool);
|
MtShadow * mt_pool_shadow(MtShadowPool *pool);
|
||||||
void mt_unpool_shadow(MtShadow *shadow);
|
void mt_unpool_shadow(MtShadow *shadow);
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
#include <shadow.h>
|
#include <shadow.h>
|
||||||
#include <context.h>
|
#include <context.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <librr/memory.h>
|
#include <string.h>
|
||||||
|
|
||||||
MtShadowLookupTree mt_create_shadow_lookup_tree()
|
MtShadowLookupTree mt_create_shadow_lookup_tree()
|
||||||
{
|
{
|
||||||
MtShadowLookupTree lookup_tree;
|
MtShadowLookupTree lookup_tree;
|
||||||
rr_memset(&lookup_tree.next[0], sizeof(MtShadow *) * 256, 0);
|
memset(&lookup_tree.next[0], sizeof(MtShadow *) * 256, 0);
|
||||||
return lookup_tree;
|
return lookup_tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
MtShadow * mt_lookup_shadow(MtShadowRegistry *registry, u32_t identifier)
|
MtShadow * mt_lookup_shadow(MtShadowRegistry *registry, uint32_t identifier)
|
||||||
{
|
{
|
||||||
u8_t index_1 = identifier >> 24;
|
uint8_t index_1 = identifier >> 24;
|
||||||
u8_t index_2 = (identifier >> 16) & 0xff;
|
uint8_t index_2 = (identifier >> 16) & 0xff;
|
||||||
u8_t index_3 = (identifier >> 8) & 0xff;
|
uint8_t index_3 = (identifier >> 8) & 0xff;
|
||||||
u8_t index_4 = identifier & 0xff;
|
uint8_t index_4 = identifier & 0xff;
|
||||||
MtShadowLookupLevel1 *level_1 = registry->lookup_tree.next[index_1];
|
MtShadowLookupLevel1 *level_1 = registry->lookup_tree.next[index_1];
|
||||||
if(level_1 == NULL)
|
if(level_1 == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -31,13 +31,13 @@ MtShadow * mt_lookup_shadow(MtShadowRegistry *registry, u32_t identifier)
|
||||||
|
|
||||||
void mt_delete_shadow(MtShadowRegistry *registry, MtShadow *shadow)
|
void mt_delete_shadow(MtShadowRegistry *registry, MtShadow *shadow)
|
||||||
{
|
{
|
||||||
u32_t identifier = shadow->identifier;
|
uint32_t identifier = shadow->identifier;
|
||||||
mt_unpool_shadow(shadow);
|
mt_unpool_shadow(shadow);
|
||||||
|
|
||||||
u8_t index_1 = identifier >> 24;
|
uint8_t index_1 = identifier >> 24;
|
||||||
u8_t index_2 = (identifier >> 16) & 0xff;
|
uint8_t index_2 = (identifier >> 16) & 0xff;
|
||||||
u8_t index_3 = (identifier >> 8) & 0xff;
|
uint8_t index_3 = (identifier >> 8) & 0xff;
|
||||||
u8_t index_4 = identifier & 0xff;
|
uint8_t index_4 = identifier & 0xff;
|
||||||
MtShadowLookupLevel1 *level_1 = registry->lookup_tree.next[index_1];
|
MtShadowLookupLevel1 *level_1 = registry->lookup_tree.next[index_1];
|
||||||
if(level_1 == NULL)
|
if(level_1 == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -52,12 +52,12 @@ void mt_delete_shadow(MtShadowRegistry *registry, MtShadow *shadow)
|
||||||
|
|
||||||
void mt_write_shadow_lookup_entry(MtShadowLookupTree *tree, MtShadow *shadow)
|
void mt_write_shadow_lookup_entry(MtShadowLookupTree *tree, MtShadow *shadow)
|
||||||
{
|
{
|
||||||
u32_t identifier = shadow->identifier;
|
uint32_t identifier = shadow->identifier;
|
||||||
|
|
||||||
u8_t index_1 = identifier >> 24;
|
uint8_t index_1 = identifier >> 24;
|
||||||
u8_t index_2 = (identifier >> 16) & 0xff;
|
uint8_t index_2 = (identifier >> 16) & 0xff;
|
||||||
u8_t index_3 = (identifier >> 8) & 0xff;
|
uint8_t index_3 = (identifier >> 8) & 0xff;
|
||||||
u8_t index_4 = identifier & 0xff;
|
uint8_t index_4 = identifier & 0xff;
|
||||||
MtShadowLookupLevel1 *level_1 = tree->next[index_1];
|
MtShadowLookupLevel1 *level_1 = tree->next[index_1];
|
||||||
if(level_1 == NULL)
|
if(level_1 == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
void mt_init_shadow_pool_allocation(MtShadowPool *pool)
|
void mt_init_shadow_pool_allocation(MtShadowPool *pool)
|
||||||
{
|
{
|
||||||
usz_t capacity = pool->capacity;
|
uint32_t capacity = pool->capacity;
|
||||||
usz_t shadow_index = 0;
|
uint32_t shadow_index = 0;
|
||||||
while(shadow_index < capacity)
|
while(shadow_index < capacity)
|
||||||
{
|
{
|
||||||
pool->shadows[shadow_index].pool = pool;
|
pool->shadows[shadow_index].pool = pool;
|
||||||
|
@ -14,7 +14,7 @@ void mt_init_shadow_pool_allocation(MtShadowPool *pool)
|
||||||
pool->shadows[capacity-1].pool_next = NULL;
|
pool->shadows[capacity-1].pool_next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mt_init_shadow_pool(MtShadowPool *pool, usz_t capacity)
|
void mt_init_shadow_pool(MtShadowPool *pool, uint32_t capacity)
|
||||||
{
|
{
|
||||||
pool->capacity = capacity;
|
pool->capacity = capacity;
|
||||||
pool->continuation = NULL;
|
pool->continuation = NULL;
|
||||||
|
@ -39,7 +39,7 @@ void mt_free_shadow_pool(MtShadowPool *pool)
|
||||||
free(pool);
|
free(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
MtShadowPool * mt_new_shadow_pool(usz_t capacity)
|
MtShadowPool * mt_new_shadow_pool(uint32_t capacity)
|
||||||
{
|
{
|
||||||
MtShadowPool *pool = malloc(sizeof(MtShadowPool));
|
MtShadowPool *pool = malloc(sizeof(MtShadowPool));
|
||||||
mt_init_shadow_pool(pool, capacity);
|
mt_init_shadow_pool(pool, capacity);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <shadow.h>
|
#include <shadow.h>
|
||||||
#include <librr/memory.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void mt_delete_shadow_lookup_tree_of_registry(MtShadowRegistry *registry);
|
void mt_delete_shadow_lookup_tree_of_registry(MtShadowRegistry *registry);
|
||||||
|
@ -29,7 +29,7 @@ void mt_cleanup_shadow_data(MtShadow *shadow)
|
||||||
void mt_delete_shadow_lookup_tree_of_registry(MtShadowRegistry *registry)
|
void mt_delete_shadow_lookup_tree_of_registry(MtShadowRegistry *registry)
|
||||||
{
|
{
|
||||||
MtShadowLookupTree *lookup_tree = ®istry->lookup_tree;
|
MtShadowLookupTree *lookup_tree = ®istry->lookup_tree;
|
||||||
u32_t index_1 = 0;
|
uint32_t index_1 = 0;
|
||||||
while(index_1 < 256)
|
while(index_1 < 256)
|
||||||
{
|
{
|
||||||
MtShadowLookupLevel1 *level_1 = lookup_tree->next[index_1];
|
MtShadowLookupLevel1 *level_1 = lookup_tree->next[index_1];
|
||||||
|
@ -38,7 +38,7 @@ void mt_delete_shadow_lookup_tree_of_registry(MtShadowRegistry *registry)
|
||||||
++index_1;
|
++index_1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
u32_t index_2 = 0;
|
uint32_t index_2 = 0;
|
||||||
while(index_2 < 256)
|
while(index_2 < 256)
|
||||||
{
|
{
|
||||||
MtShadowLookupLevel2 *level_2 = level_1->next[index_2];
|
MtShadowLookupLevel2 *level_2 = level_1->next[index_2];
|
||||||
|
@ -47,7 +47,7 @@ void mt_delete_shadow_lookup_tree_of_registry(MtShadowRegistry *registry)
|
||||||
++index_2;
|
++index_2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
u32_t index_3 = 0;
|
uint32_t index_3 = 0;
|
||||||
while(index_3 < 256)
|
while(index_3 < 256)
|
||||||
{
|
{
|
||||||
MtShadowLookupLevel3 *level_3 = level_2->next[index_3];
|
MtShadowLookupLevel3 *level_3 = level_2->next[index_3];
|
||||||
|
@ -56,7 +56,7 @@ void mt_delete_shadow_lookup_tree_of_registry(MtShadowRegistry *registry)
|
||||||
++index_3;
|
++index_3;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
u32_t index_4 = 0;
|
uint32_t index_4 = 0;
|
||||||
while(index_4 < 256)
|
while(index_4 < 256)
|
||||||
{
|
{
|
||||||
MtShadow *shadow = level_3->next[index_4];
|
MtShadow *shadow = level_3->next[index_4];
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#include <shadow-tag.h>
|
#include <shadow-tag.h>
|
||||||
#include <context.h>
|
#include <context.h>
|
||||||
#include <librr/memory.h>
|
#include <string.h>
|
||||||
#include <librr/strutil.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void mt_init_shadow_tag_pool_allocation(MtShadowTagPool *pool, usz_t capacity)
|
void mt_init_shadow_tag_pool_allocation(MtShadowTagPool *pool, uint32_t capacity)
|
||||||
{
|
{
|
||||||
usz_t slot_index = 0;
|
uint32_t slot_index = 0;
|
||||||
while(slot_index < capacity)
|
while(slot_index < capacity)
|
||||||
{
|
{
|
||||||
pool->allocation[slot_index].pool = pool;
|
pool->allocation[slot_index].pool = pool;
|
||||||
|
@ -16,7 +15,7 @@ void mt_init_shadow_tag_pool_allocation(MtShadowTagPool *pool, usz_t capacity)
|
||||||
pool->allocation[capacity - 1].next = NULL;
|
pool->allocation[capacity - 1].next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mt_init_shadow_tag_pool(MtShadowTagPool *pool, usz_t capacity)
|
void mt_init_shadow_tag_pool(MtShadowTagPool *pool, uint32_t capacity)
|
||||||
{
|
{
|
||||||
pool->capacity = capacity;
|
pool->capacity = capacity;
|
||||||
pool->allocation = calloc(sizeof(MtShadowTag), capacity);
|
pool->allocation = calloc(sizeof(MtShadowTag), capacity);
|
||||||
|
@ -25,7 +24,7 @@ void mt_init_shadow_tag_pool(MtShadowTagPool *pool, usz_t capacity)
|
||||||
mt_init_shadow_tag_pool_allocation(pool, capacity);
|
mt_init_shadow_tag_pool_allocation(pool, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
MtShadowTagPool * mt_new_shadow_tag_pool(usz_t capacity)
|
MtShadowTagPool * mt_new_shadow_tag_pool(uint32_t capacity)
|
||||||
{
|
{
|
||||||
MtShadowTagPool *pool = malloc(sizeof(MtShadowTagPool));
|
MtShadowTagPool *pool = malloc(sizeof(MtShadowTagPool));
|
||||||
mt_init_shadow_tag_pool(pool, capacity * 2);
|
mt_init_shadow_tag_pool(pool, capacity * 2);
|
||||||
|
@ -52,7 +51,7 @@ MtShadowTag * mt_alloc_shadow_tag_in_pool(MtShadowTagPool *pool)
|
||||||
pool->first_free = allocated_tag->next;
|
pool->first_free = allocated_tag->next;
|
||||||
|
|
||||||
// Reset the tag's old data
|
// Reset the tag's old data
|
||||||
rr_memset(allocated_tag, sizeof(MtShadowTag), 0x00);
|
memset(allocated_tag, sizeof(MtShadowTag), 0x00);
|
||||||
allocated_tag->pool = pool;
|
allocated_tag->pool = pool;
|
||||||
|
|
||||||
return allocated_tag;
|
return allocated_tag;
|
||||||
|
@ -85,7 +84,7 @@ void mt_free_shadow_tag_chain(MtShadowTag *tag)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void mt_init_shadow_tag_name_arena(MtShadowTagNameArena *arena, usz_t size)
|
void mt_init_shadow_tag_name_arena(MtShadowTagNameArena *arena, uint32_t size)
|
||||||
{
|
{
|
||||||
arena->usage = 0;
|
arena->usage = 0;
|
||||||
arena->capacity = size;
|
arena->capacity = size;
|
||||||
|
@ -93,7 +92,7 @@ void mt_init_shadow_tag_name_arena(MtShadowTagNameArena *arena, usz_t size)
|
||||||
arena->continuation = NULL;
|
arena->continuation = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MtShadowTagNameArena * mt_new_shadow_tag_name_arena(usz_t size)
|
MtShadowTagNameArena * mt_new_shadow_tag_name_arena(uint32_t size)
|
||||||
{
|
{
|
||||||
MtShadowTagNameArena *arena = malloc(sizeof(MtShadowTagNameArena));
|
MtShadowTagNameArena *arena = malloc(sizeof(MtShadowTagNameArena));
|
||||||
mt_init_shadow_tag_name_arena(arena, size);
|
mt_init_shadow_tag_name_arena(arena, size);
|
||||||
|
@ -137,9 +136,9 @@ void mt_cleanup_shadow_tag_system(MtShadowTagSystem *tag_system)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char * mt_shadow_tag_name_arena_alloc(MtShadowTagNameArena *arena, usz_t num_bytes)
|
char * mt_shadow_tag_name_arena_alloc(MtShadowTagNameArena *arena, uint32_t num_bytes)
|
||||||
{
|
{
|
||||||
usz_t end_size = arena->usage + num_bytes;
|
uint32_t end_size = arena->usage + num_bytes;
|
||||||
if(end_size >= arena->capacity)
|
if(end_size >= arena->capacity)
|
||||||
{
|
{
|
||||||
if(arena->continuation == NULL)
|
if(arena->continuation == NULL)
|
||||||
|
@ -151,7 +150,7 @@ char * mt_shadow_tag_name_arena_alloc(MtShadowTagNameArena *arena, usz_t num_byt
|
||||||
return allocation;
|
return allocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32_t mt_force_create_new_tag_name_entry(MtShadowTagNameRegistry *name_registry, const char *tag_name)
|
uint32_t mt_force_create_new_tag_name_entry(MtShadowTagNameRegistry *name_registry, const char *tag_name)
|
||||||
{
|
{
|
||||||
if(name_registry->num_names >= name_registry->names_capacity)
|
if(name_registry->num_names >= name_registry->names_capacity)
|
||||||
{
|
{
|
||||||
|
@ -160,9 +159,9 @@ u32_t mt_force_create_new_tag_name_entry(MtShadowTagNameRegistry *name_registry,
|
||||||
}
|
}
|
||||||
MtShadowTagName *name_entry = &name_registry->names[name_registry->num_names++];
|
MtShadowTagName *name_entry = &name_registry->names[name_registry->num_names++];
|
||||||
|
|
||||||
usz_t len_tag_name = rr_measure_string(tag_name);
|
uint32_t len_tag_name = strlen(tag_name);
|
||||||
char *tag_name_copy = mt_shadow_tag_name_arena_alloc(name_registry->root_arena, len_tag_name+1);
|
char *tag_name_copy = mt_shadow_tag_name_arena_alloc(name_registry->root_arena, len_tag_name+1);
|
||||||
rr_memcopy(tag_name_copy, tag_name, len_tag_name + 1);
|
memcpy(tag_name_copy, tag_name, len_tag_name + 1);
|
||||||
|
|
||||||
name_entry->string_in_arena = tag_name_copy;
|
name_entry->string_in_arena = tag_name_copy;
|
||||||
name_entry->identifier = name_registry->id_counter++;
|
name_entry->identifier = name_registry->id_counter++;
|
||||||
|
@ -170,15 +169,15 @@ u32_t mt_force_create_new_tag_name_entry(MtShadowTagNameRegistry *name_registry,
|
||||||
return name_entry->identifier;
|
return name_entry->identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32_t mt_tag_name_to_id(void *context_ptr, const char *tag_name)
|
uint32_t mt_tag_name_to_id(void *context_ptr, const char *tag_name)
|
||||||
{
|
{
|
||||||
MtContext *context = context_ptr;
|
MtContext *context = context_ptr;
|
||||||
MtShadowTagNameRegistry *name_registry = &context->shadow_tag_system.name_registry;
|
MtShadowTagNameRegistry *name_registry = &context->shadow_tag_system.name_registry;
|
||||||
|
|
||||||
usz_t name_index = 0;
|
uint32_t name_index = 0;
|
||||||
while(name_index < name_registry->num_names)
|
while(name_index < name_registry->num_names)
|
||||||
{
|
{
|
||||||
if(rr_strings_equal(name_registry->names[name_index].string_in_arena, tag_name))
|
if(!strcmp(name_registry->names[name_index].string_in_arena, tag_name))
|
||||||
return name_registry->names[name_index].identifier;
|
return name_registry->names[name_index].identifier;
|
||||||
++name_index;
|
++name_index;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue