summaryrefslogtreecommitdiff
path: root/src/waffle/core/wcore_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/waffle/core/wcore_util.c')
-rw-r--r--src/waffle/core/wcore_util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/waffle/core/wcore_util.c b/src/waffle/core/wcore_util.c
index b2dafe4..eee064d 100644
--- a/src/waffle/core/wcore_util.c
+++ b/src/waffle/core/wcore_util.c
@@ -28,6 +28,28 @@
#include "wcore_error.h"
#include "wcore_util.h"
+bool
+wcore_add_size(size_t *res, size_t x, size_t y)
+{
+ if (x > SIZE_MAX - y) {
+ return false;
+ }
+
+ *res = x + y;
+ return true;
+}
+
+bool
+wcore_mul_size(size_t *res, size_t x, size_t y)
+{
+ if (x > SIZE_MAX / y) {
+ return false;
+ }
+
+ *res = x * y;
+ return true;
+}
+
void*
wcore_malloc(size_t size)
{