diff options
-rw-r--r-- | src/fastd.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/fastd.h b/src/fastd.h index 8b96e14..dc69760 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -293,7 +293,9 @@ static inline size_t alignto(size_t l, size_t a) { static inline fastd_buffer fastd_buffer_alloc(size_t len, size_t head_space, size_t tail_space) { size_t base_len = head_space+len+tail_space; void *ptr; - posix_memalign(&ptr, 16, base_len); + if (posix_memalign(&ptr, 16, base_len)) + return (fastd_buffer){ .base = NULL, .base_len = 0, .data = NULL, .len = 0 }; + return (fastd_buffer){ .base = ptr, .base_len = base_len, .data = ptr+head_space, .len = len }; } |