summaryrefslogtreecommitdiff
path: root/src/util/util.h
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-01-04 18:49:47 -0600
committersanine <sanine.not@pm.me>2023-01-04 18:49:47 -0600
commitdcb7a5389717c33f7fcfa67f5e2048cacc55d820 (patch)
treea32e1f64e1e720739e94f9b89e61addaa55882a5 /src/util/util.h
parent13a7c902c051fa8da1e476687c17bb5431d258e1 (diff)
add kai_text_to_reals
Diffstat (limited to 'src/util/util.h')
-rw-r--r--src/util/util.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/util/util.h b/src/util/util.h
index c2f01eb..d6cdd20 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -1,6 +1,34 @@
#ifndef KALMIA_UTIL_H
#define KALMIA_UTIL_H
+#include <kalmia.h>
+
+
+/** @brief add a new element to an array
+ *
+ * @param array Pointer to the array to expand
+ * @param len Pointer to the current length of the array
+ * @param element_size Size of each element in the array
+ *
+ * @returns A pointer to the newly added element of the array, or NULL on failure.
+ */
void * kai_expand_array(void **array, size_t *len, size_t element_size);
+
+/** @brief Convert a string to an array of reals
+ *
+ * This function will always fill the array with `count` elements. If there are not
+ * `count` elements to be converted in the string, it will fill the rest of the array
+ * with zeroes.
+ *
+ * @param dest Array of reals in which to store the results
+ * @param str The string to convert
+ * @param count The number of elements to convert
+ *
+ * @returns The number of conversions performed. If there were at least `count` elements
+ * in the string to convert, this is the same as `count`. If not, it is the number of
+ * actual elements present in the string.
+ */
+int kai_text_to_reals(ka_real_t *dest, const char *str, size_t count);
+
#endif