From 570c4da40a76ac9ec8fddfbab202b9290d7d44e5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 9 Apr 2019 10:28:59 +0200 Subject: Allocate nodes with posix_memalign when available This fixes platforms where the system malloc returns memory that is not aligned to sizeof(SerdNode) (128 bits). --- src/system.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/system.h') diff --git a/src/system.h b/src/system.h index f17eb278..dcb5dbaa 100644 --- a/src/system.h +++ b/src/system.h @@ -1,5 +1,5 @@ /* - Copyright 2011-2018 David Robillard + Copyright 2011-2019 David Robillard Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -38,6 +38,12 @@ serd_file_read_byte(void* buf, size_t size, size_t nmemb, void* stream) return 1; } +/** Allocate a buffer aligned to `alignment` bytes. */ +void* serd_malloc_aligned(size_t size, size_t alignment); + +/** Allocate a zeroed buffer aligned to `alignment` bytes. */ +void* serd_calloc_aligned(size_t size, size_t alignment); + /** Allocate an aligned buffer for I/O. */ void* serd_allocate_buffer(size_t size); -- cgit v1.2.1