27#define TINYIMG_MAX_PIXELS 16000000u
42#define TINYIMG_MAX_IMAGE_BYTES 33554432u
49#define TINYIMG_ALIGNMENT 16u
55#define TINYIMG_HEAP_MAX 67108864u
57#pragma region primitives
321#define TINYIMG_MAX_BLOBS 8
326#define TINYIMG_BLOB_ID_MAX 32
344 TinyBlobKind kind,
const char*
id,
const uint8_t* data,
size_t size
375 TinyBlobKind kind, uint32_t index,
const char**
id,
size_t* size
const uint8_t * tiny_blob_get(TinyBlobKind kind, const char *id, size_t *size)
Looks up a resident blob.
void tiny_arena_mark(TinyArenaMark *mark)
Records the current arena position.
void * tiny_realloc(void *pointer, size_t size)
Resizes a block, moving it only when it cannot grow in place.
int tiny_memcmp(const void *s1, const void *s2, size_t n)
Replicates the behavior of the standard memcmp function, comparing the first n bytes of the memory ar...
TinyBlobKind
Kinds of data the library reads but does not ship.
Definition memory.h:303
@ TINYIMG_BLOB_FONT
A TrueType, OpenType, PSF or BDF face.
Definition memory.h:307
@ TINYIMG_BLOB_CASCADE
A packed detection cascade.
Definition memory.h:315
@ TINYIMG_BLOB_ICC
An ICC color profile.
Definition memory.h:311
void * tiny_memset(void *s, int c, size_t n)
Replicates the behavior of the standard memset function, filling the first n bytes of the memory area...
int tiny_blob_load(TinyBlobKind kind, const char *id, const uint8_t *data, size_t size)
Registers a blob under an id.
const uint8_t * tiny_blob_at(TinyBlobKind kind, uint32_t index, const char **id, size_t *size)
Walks the resident blobs of one kind.
void tiny_heap_bootstrap(void)
Installs the platform's default heap if no heap exists yet.
void tiny_arena_release(const TinyArenaMark *mark)
Rewinds the arena to a recorded position.
void tiny_free(void *pointer)
Returns a block to the heap, coalescing it with free neighbors.
void * tiny_alloc(size_t size)
Allocates a block from the heap.
int tiny_heap_init(void *memory, size_t size)
Installs a caller supplied block as the heap.
size_t tiny_arena_reserved(void)
Bytes the arena currently holds from the heap.
void * tiny_memcpy(void *dest, const void *src, size_t n)
Replicates the behavior of the standard memcpy function, copying n bytes from src to dest.
int tiny_blob_free(TinyBlobKind kind, const char *id)
Releases one resident blob.
int tiny_heap_stats(TinyHeapStats *stats)
Reads the current heap occupancy.
void * tiny_memmove(void *dest, const void *src, size_t n)
Replicates the behavior of the standard memmove function, copying n bytes from src to dest....
void tiny_arena_reset(void)
Releases every block the arena has handed out.
size_t tiny_alloc_size(const void *pointer)
Usable size of a block, which may exceed what was asked for.
void * tiny_arena_alloc(size_t size, size_t alignment)
Allocates a block from the arena, aligned to the requested boundary.
void tiny_blob_free_all(void)
Releases every resident blob.
A saved arena position.
Definition memory.h:233
size_t used
Definition memory.h:237
void * chunk
Definition memory.h:235
A snapshot of heap occupancy.
Definition memory.h:152
uint32_t free_blocks
Definition memory.h:164
size_t peak
Definition memory.h:160
size_t available
Definition memory.h:158
size_t capacity
Definition memory.h:154
size_t used
Definition memory.h:156
uint32_t blocks
Definition memory.h:162