#include /* todo get this working proper. i don't think it's possible in X however. */ /* #include "memory.h" #include "config.h" Heap ui_heap = { 0 }; static void try_init_heap(void) { if (!ui_heap.buffer) { init_heap( &ui_heap, galloc(ui_memory_size), ui_memory_size ); } } void* ui_malloc(size_t size) { try_init_heap(); return heap_alloc(&ui_heap, size); } void ui_free(void* ptr) { try_init_heap(); heap_free(&ui_heap, ptr); } void* ui_realloc(void* ptr, size_t size) { void* old; size_t os, diff; if (!ptr) return ui_malloc(size); if (!size && ptr) ui_free(ptr); os = heap_block_size(ptr); if (size == os) return ptr; diff = size; if (size > os) diff = os; old = ptr; ptr = ui_malloc(size); memcpy(ptr, old, diff); ui_free(old); return ptr; } void* ui_calloc(size_t c, size_t s) { void* p; s *= c; p = ui_malloc(s); memset(p, 0, s); return p; } #ifdef malloc #undef malloc #endif #ifdef free #undef free #endif #ifdef realloc #undef realloc #endif #ifdef calloc #undef calloc #endif #define malloc ui_malloc #define free ui_free #define realloc ui_realloc #define calloc ui_calloc */ #define UI_IMPLEMENTATION #include "luigi.h" /* #undef malloc #undef free #undef realloc #undef calloc */