aboutsummaryrefslogtreecommitdiff
path: root/libffwd/alloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'libffwd/alloc.h')
-rw-r--r--libffwd/alloc.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/libffwd/alloc.h b/libffwd/alloc.h
index 0712e21..a12ee7a 100644
--- a/libffwd/alloc.h
+++ b/libffwd/alloc.h
@@ -3,11 +3,9 @@
#include <stddef.h>
-/* Overflow-checked size arithmetic and typed (re)allocation helpers shared by
- * the model loader, the forward pass, and the late-interaction code. Every
- * helper returns -1 (or NULL) on overflow or allocation failure so callers can
- * bail without a partial buffer. realloc_* keep the original pointer intact on
- * failure; the caller still owns it. */
+/* 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);
@@ -15,20 +13,19 @@ int mul_size(size_t a, size_t b, size_t *out);
/* out = a + b, or -1 if the sum overflows size_t. */
int add_size(size_t a, size_t b, size_t *out);
-/* Round a requested sequence capacity up to the workspace growth granularity,
- * never shrinking below the current capacity. Returns -1 on bad input/overflow. */
+/* Grow sequence capacity without shrinking. */
int grow_cap(int current, int needed, int *out);
-/* realloc *ptr to hold `count` floats; *ptr unchanged on failure. */
+/* realloc *ptr to hold count floats; *ptr unchanged on failure. */
int realloc_floats(float **ptr, size_t count);
-/* malloc `count` floats, NULL on overflow/failure. */
+/* malloc count floats, NULL on overflow/failure. */
float *malloc_floats(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);
-/* realloc *ptr to hold `count` ints; *ptr unchanged on failure. */
+/* realloc *ptr to hold count ints; *ptr unchanged on failure. */
int realloc_ints(int **ptr, size_t count);
#endif /* FFWD_ALLOC_H */