aboutsummaryrefslogtreecommitdiffstats
path: root/src/system.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-02-24 21:07:07 -0500
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:05 -0500
commit36e2f27502524155e6475a75ffcab4999fce166a (patch)
treec193ccab896fa63a48e0dba5eecfccfc9ec46a2b /src/system.c
parent02507b57fae1e29572a11be8894b7dde9048da5d (diff)
downloadserd-36e2f27502524155e6475a75ffcab4999fce166a.tar.gz
serd-36e2f27502524155e6475a75ffcab4999fce166a.tar.bz2
serd-36e2f27502524155e6475a75ffcab4999fce166a.zip
Align node allocations
Diffstat (limited to 'src/system.c')
-rw-r--r--src/system.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/system.c b/src/system.c
index 4f6c37c6..323ed62e 100644
--- a/src/system.c
+++ b/src/system.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
void*
serd_malloc_aligned(const size_t alignment, const size_t size)
@@ -44,6 +45,21 @@ serd_malloc_aligned(const size_t alignment, const size_t size)
}
void*
+serd_calloc_aligned(const size_t alignment, const size_t size)
+{
+#if defined(_WIN32) || defined(USE_POSIX_MEMALIGN)
+ void* const ptr = serd_malloc_aligned(alignment, size);
+ if (ptr) {
+ memset(ptr, 0, size);
+ }
+ return ptr;
+#else
+ (void)alignment;
+ return calloc(1, size);
+#endif
+}
+
+void*
serd_allocate_buffer(const size_t size)
{
return serd_malloc_aligned(SERD_PAGE_SIZE, size);