summaryrefslogtreecommitdiff
path: root/src/utils/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/utils.c')
-rw-r--r--src/utils/utils.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utils/utils.c b/src/utils/utils.c
index 1745ea0..1899b23 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -130,3 +130,19 @@ css_fixed css__number_from_string(const uint8_t *data, size_t len,
return (intpart << 10) | fracpart;
}
+
+/* Allocator to pass to libparserutils */
+void *css_alloc(void *data, size_t len, void *pw)
+{
+ UNUSED(pw);
+
+ if (data == NULL) {
+ return (len > 0) ? malloc(len) : NULL;
+ }
+ if (len == 0) {
+ free(data);
+ return NULL;
+ }
+ return realloc(data, len);
+}
+