44 if (!s || !txt || n == 0)
51 size_t newcap = s->
length + n + 1;
53 newtxt[newcap - 1] =
'\0';
58 for (
size_t i = 0; i < n; i++) {
71static inline int gm_str_append(
gmStr *s,
const char *txt) {
void * malloc(size_t size)
Custom implementation of malloc using a static memory pool.
Definition malloc.h:144
void * realloc(void *ptr, size_t size)
Custom implementation of realloc for memory allocated by malloc (this custom version).
Definition malloc.h:236
void free(void *ptr)
Custom implementation of free for memory allocated by malloc (this custom version).
Definition malloc.h:189
void gm_str_clear(gmStr *str)
Frees the heap-allocated content of a gmStr and resets its length to 0.
Definition str.h:82
gmStr gm_str()
Initializes an empty gmStr struct.
Definition str.h:30
int gm_str_appendn(gmStr *s, size_t n, const char *txt)
Appends a specified number of characters from a C string to a gmStr.
Definition str.h:43
Represents a dynamic, heap-allocated string.
Definition str.h:21
char * content
Definition str.h:23
size_t length
Definition str.h:22