Compare commits
No commits in common. "4be2d3b0188879c1d7e322586d9fddb45ba6890e" and "6150e5dda632369aa589a227e12bf1c0f1b10e07" have entirely different histories.
4be2d3b018
...
6150e5dda6
|
@ -1,26 +0,0 @@
|
|||
|
||||
# IDE/Editor - data
|
||||
.vscode/
|
||||
.eclipse/
|
||||
|
||||
# Folders that should stay local
|
||||
.private/
|
||||
.build/
|
||||
|
||||
# Executable code
|
||||
*.a
|
||||
*.dll
|
||||
*.dmg
|
||||
*.elf
|
||||
*.exe
|
||||
*.lib
|
||||
*.o
|
||||
*.out
|
||||
*.so
|
||||
|
||||
# Compiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Debug Information
|
||||
vgcore.*
|
|
@ -6,6 +6,6 @@ It currently consists of 2 independent single-header libraries
|
|||
## Functionality
|
||||
|
||||
There are only 2 libraries currently:
|
||||
1) ufn_arena: An arena allocator for optimizing string processing.
|
||||
1) ufn_arena: An arena allocator for optimization of string processing.
|
||||
2) ufn_round: Functions for rounding to the next multiple of some number
|
||||
or to the next power of 2. Currently only floor()'s and ceil()'s to those.
|
||||
|
|
|
@ -63,7 +63,6 @@ void * ufn_arena_alloc(ufn_arena_s *arena, uint32_t size);
|
|||
char * ufn_arena_clone_string(ufn_arena_s *arena, const char *string);
|
||||
|
||||
// END OF API, START OF IMPLEMENTATION.
|
||||
|
||||
#ifdef UFN_IMPLEMENTATION
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -95,13 +94,13 @@ void ufn_free_arena(ufn_arena_s *arena)
|
|||
|
||||
void * ufn_arena_alloc(ufn_arena_s *arena, uint32_t size)
|
||||
{
|
||||
if((arena->usage + size) >= arena->capacity)
|
||||
if((arena->usage = size) >= arena->capacity)
|
||||
{
|
||||
if(arena->continuation == NULL)
|
||||
{
|
||||
uint32_t continuation_size = arena->capacity * 2;
|
||||
// Clamp the continuation's size to the maximum allowed one.
|
||||
if(continuation_size > arena->maximum)
|
||||
if(continuation_size > (arena->maximum))
|
||||
{
|
||||
continuation_size = arena->maximum;
|
||||
}
|
||||
|
@ -109,7 +108,7 @@ void * ufn_arena_alloc(ufn_arena_s *arena, uint32_t size)
|
|||
// If no continuation of this arena tree can fulfill
|
||||
// a request of this size,
|
||||
// -> Deny the request and return NULL.
|
||||
if(size >= arena->maximum)
|
||||
if(size > arena->maximum)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -121,7 +120,7 @@ void * ufn_arena_alloc(ufn_arena_s *arena, uint32_t size)
|
|||
}
|
||||
arena->continuation = ufn_new_dynamic_arena(continuation_size, continued_maximum);
|
||||
}
|
||||
return ufn_arena_alloc(arena->continuation, size);
|
||||
ufn_arena_alloc(arena->continuation, size);
|
||||
}
|
||||
void *block = arena->allocation + arena->usage;
|
||||
arena->usage += size;
|
||||
|
|
Loading…
Reference in New Issue