From adafbf40caded39ab5fa83330914591fd9bf9c64 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Fri, 19 Jan 2018 20:45:15 +0100 Subject: [PATCH] util-memory: Expose aligned_offset to code --- source/util-memory.cpp | 4 ---- source/util-memory.h | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/source/util-memory.cpp b/source/util-memory.cpp index 85d0876d..cbe70241 100644 --- a/source/util-memory.cpp +++ b/source/util-memory.cpp @@ -20,10 +20,6 @@ #include "util-memory.h" #include -inline size_t aligned_offset(size_t align, size_t size) { - return ((size / align) + 1) * align; -} - void* util::malloc_aligned(size_t align, size_t size) { // Ensure that we have space for the pointer and the data. size_t asize = aligned_offset(align, size + sizeof(void*)); diff --git a/source/util-memory.h b/source/util-memory.h index d5d2ebd3..f7b15dc4 100644 --- a/source/util-memory.h +++ b/source/util-memory.h @@ -22,6 +22,9 @@ #include namespace util { + inline size_t aligned_offset(size_t align, size_t pos) { + return ((pos / align) + 1) * align; + } void* malloc_aligned(size_t align, size_t size); void free_aligned(void* mem); @@ -55,11 +58,11 @@ namespace util { } inline pointer allocate(size_type n) { - return (pointer)_aligned_malloc(n*sizeof(value_type), N); + return (pointer)malloc_aligned(n*sizeof(value_type), N); } inline void deallocate(pointer p, size_type) { - _aligned_free(p); + free_aligned(p); } inline void construct(pointer p, const value_type & wert) {