mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
Removed nonstandard C constructor attribute
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
//default allocator
|
//default allocator
|
||||||
static void* defaultMemoryAllocator(void* pointer, size_t oldSize, size_t newSize) {
|
void* Toy_private_defaultMemoryAllocator(void* pointer, size_t oldSize, size_t newSize) {
|
||||||
if (newSize == 0 && oldSize == 0) {
|
if (newSize == 0 && oldSize == 0) {
|
||||||
//causes issues, so just skip out with a NO-OP
|
//causes issues, so just skip out with a NO-OP
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -30,12 +30,7 @@ static void* defaultMemoryAllocator(void* pointer, size_t oldSize, size_t newSiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
//static variables
|
//static variables
|
||||||
static Toy_MemoryAllocatorFn allocator;
|
static Toy_MemoryAllocatorFn allocator = Toy_private_defaultMemoryAllocator;
|
||||||
|
|
||||||
//preload
|
|
||||||
static void __attribute__((constructor)) preloadMemoryAllocator() {
|
|
||||||
Toy_setMemoryAllocator(defaultMemoryAllocator);
|
|
||||||
}
|
|
||||||
|
|
||||||
//exposed API
|
//exposed API
|
||||||
void* Toy_reallocate(void* pointer, size_t oldSize, size_t newSize) {
|
void* Toy_reallocate(void* pointer, size_t oldSize, size_t newSize) {
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ STATIC_ASSERT(sizeof(int) == 4);
|
|||||||
STATIC_ASSERT(sizeof(char) == 1);
|
STATIC_ASSERT(sizeof(char) == 1);
|
||||||
|
|
||||||
//memory allocation
|
//memory allocation
|
||||||
static Toy_RefStringAllocatorFn allocate;
|
extern void* Toy_private_defaultMemoryAllocator(void* pointer, size_t oldSize, size_t newSize);
|
||||||
|
static Toy_RefStringAllocatorFn allocate = Toy_private_defaultMemoryAllocator;
|
||||||
|
|
||||||
void Toy_setRefStringAllocatorFn(Toy_RefStringAllocatorFn allocator) {
|
void Toy_setRefStringAllocatorFn(Toy_RefStringAllocatorFn allocator) {
|
||||||
allocate = allocator;
|
allocate = allocator;
|
||||||
|
|||||||
Reference in New Issue
Block a user