aboutsummaryrefslogtreecommitdiff
path: root/liblangdet/alloc.h
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-09-29 13:11:00 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-09-29 13:11:00 +0200
commit37cbaef9ceb828c667da8f398027ba5415ee7475 (patch)
tree6103e92a9030766e78a35df00f7a1155d0d0ecf5 /liblangdet/alloc.h
parentcf7d8169ec12cb3adf90d4ff78b3257e74985302 (diff)
downloadlangdet-37cbaef9ceb828c667da8f398027ba5415ee7475.tar.gz
langdet-37cbaef9ceb828c667da8f398027ba5415ee7475.zip
Rename CPU library API and sources to langdet
Diffstat (limited to 'liblangdet/alloc.h')
-rw-r--r--liblangdet/alloc.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/liblangdet/alloc.h b/liblangdet/alloc.h
new file mode 100644
index 0000000..f70f1f7
--- /dev/null
+++ b/liblangdet/alloc.h
@@ -0,0 +1,22 @@
+#ifndef LANGDET_ALLOC_H
+#define LANGDET_ALLOC_H
+
+#include <stddef.h>
+
+/* Checked size arithmetic and typed allocation helpers.
+ * Return -1 or NULL on overflow/allocation failure.
+ * realloc_* leave the original pointer unchanged on failure. */
+
+/* out = a * b, or -1 if the product overflows size_t. */
+int mul_size(size_t a, size_t b, size_t *out);
+
+/* Grow sequence capacity without shrinking. */
+int grow_cap(int current, int needed, int *out);
+
+/* realloc *ptr to hold count floats; *ptr unchanged on failure. */
+int realloc_floats(float **ptr, size_t count);
+
+/* realloc *ptr to hold rows*cols floats; -1 on negative dims/overflow/failure. */
+int realloc_floats_2d(float **ptr, int rows, int cols);
+
+#endif /* LANGDET_ALLOC_H */