Mercurial > libedl
view src/util.c @ 12:0cc2555db371
*: make our string functions not stupid
strncat() made everything slow!
new addition internally: an EDL_header structure to make things
not stupid. if we were using C++ it wouldn't really be necessary,
but alas :)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 27 Mar 2024 13:38:30 -0400 |
parents | d6f8f73a0c50 |
children | 2d7c810a1ac2 |
line wrap: on
line source
#include "util.h" #include <stdlib.h> #include <string.h> /* reimplementations of non-portable stdlib functions */ size_t EDL_internal_strnlen(const char* s, size_t maxlen) { size_t len; for (len = 0; len < maxlen; len++, s++) { if (!*s) break; } return len; } char* EDL_internal_strnchr(const char* haystack, char needle, size_t length) { for (; length && *haystack && *haystack != needle; haystack++, length--); return length ? haystack : NULL; } char* EDL_internal_strdup(const char* s) { const size_t len = strlen(s); char* d = malloc((len + 1) * sizeof(char)); memcpy(d, s, len * sizeof(char)); d[len] = '\0'; return d; }