51 lines
1.0 KiB
C
51 lines
1.0 KiB
C
#pragma once
|
|
#include <GLFW/glfw3.h>
|
|
#include <string.h>
|
|
#include <stdint.h>
|
|
#define ARENA_IMPLEMENTATION
|
|
#include "libs/arena/arena.h"
|
|
|
|
typedef uint8_t u8;
|
|
// typedef char16_t c16;
|
|
typedef uint16_t u16;
|
|
typedef int16_t i16;
|
|
typedef int32_t b32;
|
|
typedef int32_t i32;
|
|
typedef uint32_t u32;
|
|
typedef uint64_t u64;
|
|
typedef float f32;
|
|
typedef double f64;
|
|
typedef uintptr_t uptr;
|
|
typedef char byte;
|
|
typedef ptrdiff_t size;
|
|
typedef size_t usize;
|
|
|
|
typedef struct s8 {
|
|
u8* data;
|
|
usize size;
|
|
} s8;
|
|
|
|
typedef struct s8_buf {
|
|
char* data;
|
|
usize size;
|
|
usize capcity;
|
|
Arena* arena;
|
|
} str_buf;
|
|
|
|
// TODO: It would be cool to use abstract allocators
|
|
s8 cstr(char *cstr, Arena *arena) {
|
|
int size = strlen(cstr);
|
|
void *data = arena_alloc(arena, size);
|
|
memcpy(data, cstr, size);
|
|
return (s8) { (u8*)data, size };
|
|
}
|
|
|
|
void print_str(s8 string, bool print_nl) {
|
|
for (usize i = 0; i < string.size; i++) {
|
|
printf("%c", string.data[i]);
|
|
}
|
|
if (print_nl) {
|
|
printf("\n");
|
|
}
|
|
}
|