Reformat
This commit is contained in:
parent
c90874ad10
commit
034b105ea1
@ -2,7 +2,9 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Allocator API definitions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
void *wapp_mem_allocator_alloc(const Allocator *allocator, u64 size) {
|
||||
@ -48,4 +50,4 @@ void wapp_mem_allocator_free(const Allocator *allocator, void **ptr) {
|
||||
allocator->free(ptr, allocator->obj);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -8,7 +8,9 @@ extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Allocator function pointer types
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
typedef void *(MemAllocFunc)(u64 size, void *alloc_obj);
|
||||
@ -18,10 +20,12 @@ typedef void *(MemReallocAlignedFunc)(void *ptr, u64 size, u64 alignment,
|
||||
void *alloc_obj);
|
||||
typedef void(MemFreeFunc)(void **ptr, void *alloc_obj);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Allocator type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
typedef struct allocator Allocator;
|
||||
@ -34,10 +38,12 @@ struct allocator {
|
||||
MemFreeFunc *free;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Allocator API declarations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
void *wapp_mem_allocator_alloc(const Allocator *allocator, u64 size);
|
||||
@ -49,7 +55,7 @@ void *wapp_mem_allocator_realloc_aligned(const Allocator *allocator, void *ptr,
|
||||
u64 size, u64 alignment);
|
||||
void wapp_mem_allocator_free(const Allocator *allocator, void **ptr);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -25,7 +25,9 @@ struct arena {
|
||||
};
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Arena API definitions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
bool wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity,
|
||||
@ -119,4 +121,4 @@ void wapp_mem_arena_destroy(Arena **arena) {
|
||||
*arena = NULL;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -12,7 +12,9 @@ extern "C" {
|
||||
typedef struct arena Arena;
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Arena wrapper macros
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
#define wapp_mem_arena_init(arena_dptr, base_capacity) \
|
||||
@ -30,10 +32,12 @@ typedef struct arena Arena;
|
||||
WAPP_MEM_ALLOC_RESERVE | WAPP_MEM_ALLOC_COMMIT, \
|
||||
true))
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Arena API declarations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
/**
|
||||
@ -48,7 +52,7 @@ void *wapp_mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment);
|
||||
void wapp_mem_arena_clear(Arena *arena);
|
||||
void wapp_mem_arena_destroy(Arena **arena);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -2,17 +2,21 @@
|
||||
#include "mem_arena.h"
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Arena Allocator wrappers declarations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
internal inline void *mem_arena_alloc(u64 size, void *alloc_obj);
|
||||
internal inline void *mem_arena_alloc_aligned(u64 size, u64 alignment,
|
||||
void *alloc_obj);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Arena Allocator API definitions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity,
|
||||
@ -40,10 +44,12 @@ void wapp_mem_arena_allocator_destroy(Allocator *allocator) {
|
||||
*allocator = (Allocator){0};
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Arena Allocator wrappers definitions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
internal inline void *mem_arena_alloc(u64 size, void *alloc_obj) {
|
||||
@ -57,4 +63,4 @@ internal inline void *mem_arena_alloc_aligned(u64 size, u64 alignment,
|
||||
return wapp_mem_arena_alloc_aligned(arena, size, alignment);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -11,7 +11,9 @@ extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Arena Allocator wrapper macros
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
#define wapp_mem_arena_allocator_init(base_capacity) \
|
||||
@ -27,10 +29,12 @@ extern "C" {
|
||||
(wapp_mem_arena_allocator_init_custom( \
|
||||
base_capacity, WAPP_MEM_ALLOC_RESERVE | WAPP_MEM_ALLOC_COMMIT, true))
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Arena Allocator API declarations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
/**
|
||||
@ -50,7 +54,7 @@ Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity,
|
||||
void wapp_mem_arena_allocator_clear(Allocator *allocator);
|
||||
void wapp_mem_arena_allocator_destroy(Allocator *allocator);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user