diff options
author | sanine <sanine.not@pm.me> | 2023-02-06 11:59:28 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-02-06 11:59:28 -0600 |
commit | ea530015e97e5280b61f3a8bc2d2ddee5c0e2dff (patch) | |
tree | 205c7d51a24927f45e21ef98a3213b120150649a /src/util | |
parent | 3d1afa579c9ce045c87e4b68a6d6068a389251a0 (diff) |
implement kai_read_triangles
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/util.c | 20 | ||||
-rw-r--r-- | src/util/util.h | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c index 4f79870..c113377 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -64,6 +64,26 @@ size_t kai_text_to_longs(long *dest, const char *str, size_t count) } +size_t kai_text_to_uints(unsigned int *dest, const char *str, size_t count) +{ + char *nptr = (char*) str; + char *end; + + size_t result = count; + + int i; + for (i=0; i<count; i++) { + dest[i] = strtol(nptr, &end, 10); + if (nptr == end) { + result -= 1; + } + nptr = end; + } + + return result; +} + + void *kai_alloc(size_t size, const char *purpose) { void *buf = malloc(size); diff --git a/src/util/util.h b/src/util/util.h index d5fa636..67d3922 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -34,6 +34,8 @@ size_t kai_text_to_reals(ka_real_t *dest, const char *str, size_t count); size_t kai_text_to_longs(long *dest, const char *str, size_t count); +size_t kai_text_to_uints(unsigned int *dest, const char *str, size_t count); + void *kai_alloc(size_t size, const char *purpose); |