From 25a2605932f72286333d83a4e10e490107b0f6fd Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sun, 20 Sep 2020 02:40:40 +0800 Subject: [PATCH] rename hgl_aligned_malloc to hgl_align_malloc --- inc/hgl/platform/os/Android.h | 2 +- inc/hgl/platform/os/BSD.h | 2 +- inc/hgl/platform/os/Linux.h | 2 +- inc/hgl/platform/os/MacOS.h | 2 +- inc/hgl/type/ObjectList.cpp | 4 ++-- inc/hgl/type/Stack.cpp | 16 ++++++++-------- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/inc/hgl/platform/os/Android.h b/inc/hgl/platform/os/Android.h index fc2af35..1f505d6 100644 --- a/inc/hgl/platform/os/Android.h +++ b/inc/hgl/platform/os/Android.h @@ -37,7 +37,7 @@ #define hgl_free free template -inline T *hgl_aligned_malloc(size_t n) +inline T *hgl_align_malloc(size_t n) { return (T *)memalign(alignof(T),n*sizeof(T)); } diff --git a/inc/hgl/platform/os/BSD.h b/inc/hgl/platform/os/BSD.h index 80ad19c..5e410cb 100644 --- a/inc/hgl/platform/os/BSD.h +++ b/inc/hgl/platform/os/BSD.h @@ -45,7 +45,7 @@ #define hgl_free free template -inline T *hgl_aligned_malloc(size_t n) +inline T *hgl_align_malloc(size_t n) { return (T *)aligned_alloc(alignof(T),n*sizeof(T)); } diff --git a/inc/hgl/platform/os/Linux.h b/inc/hgl/platform/os/Linux.h index f8b915d..2c20647 100644 --- a/inc/hgl/platform/os/Linux.h +++ b/inc/hgl/platform/os/Linux.h @@ -37,7 +37,7 @@ #define hgl_free free template -inline T *hgl_aligned_malloc(size_t n) +inline T *hgl_align_malloc(size_t n) { return (T *)aligned_alloc(alignof(T),n*sizeof(T)); } diff --git a/inc/hgl/platform/os/MacOS.h b/inc/hgl/platform/os/MacOS.h index 9acbc6f..5d8babf 100644 --- a/inc/hgl/platform/os/MacOS.h +++ b/inc/hgl/platform/os/MacOS.h @@ -41,7 +41,7 @@ #define hgl_free free template -inline T *hgl_aligned_malloc(size_t n) +inline T *hgl_align_malloc(size_t n) { return (T *)hgl_malloc(n*sizeof(T)); } diff --git a/inc/hgl/type/ObjectList.cpp b/inc/hgl/type/ObjectList.cpp index ef55dc2..dbac8bb 100644 --- a/inc/hgl/type/ObjectList.cpp +++ b/inc/hgl/type/ObjectList.cpp @@ -22,7 +22,7 @@ namespace hgl // if(!this->items) // { // this->max_count=1; -// this->items=(T **)hgl_aligned_malloc(1); +// this->items=(T **)hgl_align_malloc(1); // } // else // { @@ -238,7 +238,7 @@ namespace hgl } // else // { -// this->items=(T **)hgl_aligned_malloc(this->max_count); +// this->items=(T **)hgl_align_malloc(this->max_count); // // while(new_count--) // this->items[this->count++]=CreateObject(); diff --git a/inc/hgl/type/Stack.cpp b/inc/hgl/type/Stack.cpp index 89d1c7c..75d41d9 100644 --- a/inc/hgl/type/Stack.cpp +++ b/inc/hgl/type/Stack.cpp @@ -17,7 +17,7 @@ namespace hgl { max_count=m; - items=hgl_aligned_malloc(max_count); + items=hgl_align_malloc(max_count); } else max_count=0; @@ -42,13 +42,13 @@ namespace hgl if(alloc_count==0) { alloc_count=power_to_2(m); - items=hgl_aligned_malloc(alloc_count); + items=hgl_align_malloc(alloc_count); } else if(alloc_count(items,alloc_count); } max_count=m; @@ -169,12 +169,12 @@ namespace hgl { alloc_count=power_to_2(cur_count+1); - items=(T *)hgl_realloc(items,alloc_count*sizeof(T)); + items=(T *)hgl_align_realloc(items,alloc_count); } } else { - items=hgl_aligned_malloc(1); + items=hgl_align_malloc(1); alloc_count=1; } @@ -209,12 +209,12 @@ namespace hgl { alloc_count=power_to_2(cur_count+data_count); - items=(T *)hgl_realloc(items,alloc_count*sizeof(T)); + items=(T *)hgl_align_realloc(items,alloc_count); } } else { - items=hgl_aligned_malloc(data_count); + items=hgl_align_malloc(data_count); alloc_count=data_count; } @@ -241,7 +241,7 @@ namespace hgl else alloc_count=max_count; - items=hgl_aligned_malloc(alloc_count); + items=hgl_align_malloc(alloc_count); memcpy(items,ori.items,alloc_count*sizeof(T)); }