define pst_alloc & pst_free macro to use global allocator

This commit is contained in:
2020-02-01 17:57:43 +04:00
parent e27f0c5c18
commit 7c13dfa9e1
8 changed files with 50 additions and 46 deletions
+2 -4
View File
@@ -20,11 +20,11 @@
TYPE NAME; CAT2(TYPE, _init) (&NAME, __VA_ARGS__);
// allocation with initialization
#define pst_alloc(TYPE, NAME, ...) \
#define pst_new(TYPE, NAME, ...) \
TYPE* NAME; NAME = CAT2(TYPE, _new) (__VA_ARGS__);
// de-initialization and deletion if was previously allocated
#define pst_free(TYPE, NAME) \
#define pst_fini(TYPE, NAME) \
CAT2(TYPE, _fini) (NAME);
typedef struct __pst_allocator pst_allocator;
@@ -53,6 +53,4 @@ void pst_alloc_init(pst_allocator* alloc);
void pst_alloc_init_custom(pst_allocator* alloc, void* buff, uint32_t size);
void pst_alloc_fini(pst_allocator* alloc);
char* pst_dup(pst_allocator* alloc, const char* str);
#endif /* PST_ALLOCATOR_H_ */