Reformat
This commit is contained in:
parent
a7e98211f9
commit
98829b8400
@ -1,12 +1,6 @@
|
||||
#include "mem_allocator.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Allocator API definitions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
void *wapp_mem_allocator_alloc(const Allocator *allocator, u64 size) {
|
||||
if (!allocator || !(allocator->alloc)) {
|
||||
return NULL;
|
||||
|
@ -2,28 +2,18 @@
|
||||
#define MEM_ALLOCATOR_H
|
||||
|
||||
#include "aliases.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // __cplusplus
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Allocator function pointer types
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
typedef void *(MemAllocFunc)(u64 size, void *alloc_obj);
|
||||
typedef void *(MemAllocAlignedFunc)(u64 size, u64 alignment, void *alloc_obj);
|
||||
typedef void *(MemReallocFunc)(void *ptr, u64 old_size, u64 new_size, void *alloc_obj);
|
||||
typedef void *(MemReallocAlignedFunc)(void *ptr, u64 old_size, u64 new_size, u64 alignment, void *alloc_obj);
|
||||
typedef void(MemFreeFunc)(void **ptr, void *alloc_obj);
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Allocator type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
typedef struct allocator Allocator;
|
||||
struct allocator {
|
||||
@ -35,11 +25,8 @@ struct allocator {
|
||||
MemFreeFunc *free;
|
||||
};
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Allocator API declarations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
#define wapp_mem_allocator_invalid(ALLOCATOR) (memcmp(ALLOCATOR, &((Allocator){0}), sizeof(Allocator)) == 0)
|
||||
|
||||
void *wapp_mem_allocator_alloc(const Allocator *allocator, u64 size);
|
||||
void *wapp_mem_allocator_alloc_aligned(const Allocator *allocator, u64 size, u64 alignment);
|
||||
|
@ -1,23 +1,12 @@
|
||||
#include "mem_arena_allocator.h"
|
||||
#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);
|
||||
internal inline void *mem_arena_realloc(void *ptr, u64 old_size, u64 new_size, void *alloc_obj);
|
||||
internal inline void *mem_arena_realloc_aligned(void *ptr, u64 old_size, u64 new_size, u64 alignment,
|
||||
void *alloc_obj);
|
||||
|
||||
/***************************************************************************/ //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// Arena Allocator API definitions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/***************************************************************************/ //
|
||||
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, bool zero_buffer) {
|
||||
Allocator allocator = {0};
|
||||
@ -43,11 +32,6 @@ 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) {
|
||||
Arena *arena = (Arena *)alloc_obj;
|
||||
|
Loading…
Reference in New Issue
Block a user