summaryrefslogtreecommitdiff
path: root/src/util/string.c
diff options
context:
space:
mode:
authorDennis Camera <skonfig@dtnr.ch>2022-08-21 10:07:29 +0200
committerDennis Camera <skonfig@dtnr.ch>2022-08-21 10:07:59 +0200
commit6ed18ee1677007b9870fad63b8ef11e7d9afe0d9 (patch)
tree42222b1b895bc9f77383dbbd2cee924834d15927 /src/util/string.c
parentdb2282253024c86d16622ca7650768cd476c023d (diff)
downloadskonfig-c-6ed18ee1677007b9870fad63b8ef11e7d9afe0d9.tar.gz
skonfig-c-6ed18ee1677007b9870fad63b8ef11e7d9afe0d9.zip
Work around void * arithmetic errors
...but the data structure should probably be reworked instead of relying on the optional uintptr_t type :-/
Diffstat (limited to 'src/util/string.c')
-rw-r--r--src/util/string.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/util/string.c b/src/util/string.c
index d5ad73b..c760b06 100644
--- a/src/util/string.c
+++ b/src/util/string.c
@@ -4,6 +4,8 @@
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
+
#ifndef HAVE_STRDUP
char *strdup(const char *s) {
if (NULL == s) {
@@ -143,12 +145,12 @@ size_t strsplit(const char *restrict in, const char *restrict sep, void *buf) {
if (arr) {
/* update array pointers */
for (int j = 0; j < i; j++) {
- arr[j] = (char *)((size_t)buf + strtokoffset + (size_t)arr[j]);
+ arr[j] = (char *)((uintptr_t)buf + strtokoffset + (size_t)arr[j]);
}
arr[i] = NULL; /* NULL termination */
/* copy tokenized string from tmp to the back of buf */
- (void)memcpy(buf + strtokoffset, tmp, strtoklen);
+ (void)memcpy((void *)((uintptr_t)buf + strtokoffset), tmp, strtoklen);
}
free(tmp);