31 lines
719 B
C
31 lines
719 B
C
#include "ui_data.h"
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
|
|
const size_t uiDataLength = UI_DATA_SIZE;
|
|
|
|
static size_t utilized = 0;
|
|
static char uiDataArena[UI_DATA_SIZE];
|
|
static char *uiDataWriter = uiDataArena;
|
|
|
|
Clay_String UiData_StoreString(char const *data, size_t amount) {
|
|
if (utilized + amount > uiDataLength) {
|
|
return CLAY_STRING("out of arena memory");
|
|
}
|
|
memcpy(uiDataWriter, data, amount);
|
|
Clay_String result = {
|
|
false, (int32_t)amount, uiDataWriter
|
|
};
|
|
uiDataWriter += amount;
|
|
utilized += amount;
|
|
return result;
|
|
}
|
|
Clay_String UiData_StoreClayStr(Clay_String string) {
|
|
return UiData_StoreString(string.chars, string.length);
|
|
}
|
|
|
|
void UiData_Clear() {
|
|
utilized = 0;
|
|
uiDataWriter = uiDataArena;
|
|
}
|