diff options
author | quou <quou@disroot.org> | 2024-06-02 21:46:07 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-06-02 21:47:26 +1000 |
commit | 62b4a3ededd237f4b4850d91c052585e2f687499 (patch) | |
tree | 25bf590a634c6c71f399cf9b1d620500f06b8b9f /luigi.c | |
parent | 2e761bdb8badecdbda2925a056a6d5aa3e3cac83 (diff) |
Switched to luigi, parsing out FLAC metadata.
Diffstat (limited to 'luigi.c')
-rw-r--r-- | luigi.c | 87 |
1 files changed, 87 insertions, 0 deletions
@@ -0,0 +1,87 @@ +#include <stddef.h> + +/* +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 +*/ |