forked from DareksCoffee/GlyphGL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglyph_util.h
More file actions
72 lines (63 loc) · 2.09 KB
/
Copy pathglyph_util.h
File metadata and controls
72 lines (63 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* GlyphGL Utility Header - Memory Management and Debugging Macros
*
* This header provides configurable memory management functions and debugging
* utilities for the GlyphGL library. All memory operations can be overridden
* by defining custom GLYPH_MALLOC, GLYPH_FREE, and GLYPH_REALLOC macros before
* including this header, allowing integration with custom allocators.
*
* The debugging system provides conditional logging that can be enabled by
* defining GLYPHGL_DEBUG before including GlyphGL headers.
*/
#ifndef GLYPH_UTIL_H
#define GLYPH_UTIL_H
#include <stdlib.h>
#include <stdint.h>
/* Portable byte swap functions for C99 compatibility */
static inline uint16_t glyph__bswap16(uint16_t val) {
return (val << 8) | (val >> 8);
}
static inline uint32_t glyph__bswap32(uint32_t val) {
return ((val & 0xFF) << 24) | ((val & 0xFF00) << 8) | ((val & 0xFF0000) >> 8) | ((val & 0xFF000000) >> 24);
}
/*
* Memory allocation macro - defaults to standard malloc
*
* Can be overridden by defining GLYPH_MALLOC before including this header.
* This allows GlyphGL to work with custom memory allocators or memory pools.
*/
#ifndef GLYPH_MALLOC
#define GLYPH_MALLOC malloc
#endif
/*
* Memory deallocation macro - defaults to standard free
*
* Can be overridden by defining GLYPH_FREE before including this header.
* Must be paired with the corresponding GLYPH_MALLOC implementation.
*/
#ifndef GLYPH_FREE
#define GLYPH_FREE free
#endif
/*
* Memory reallocation macro - defaults to standard realloc
*
* Can be overridden by defining GLYPH_REALLOC before including this header.
* Used for dynamic buffer growth in vertex batching and other operations.
*/
#ifndef GLYPH_REALLOC
#define GLYPH_REALLOC realloc
#endif
/*
* Debug logging macro - conditionally compiled based on GLYPHGL_DEBUG
*
* When GLYPHGL_DEBUG is defined, this expands to printf() calls for logging.
* When not defined, it compiles to nothing, eliminating runtime overhead.
*
* Usage: GLYPH_LOG("Error: %s\n", error_message);
*/
#ifdef GLYPHGL_DEBUG
#define GLYPH_LOG(...) printf(__VA_ARGS__)
#else
#define GLYPH_LOG(...)
#endif
#endif