Skip to content

Commit 7ba244b

Browse files
committed
add memalign 0 byte check
1 parent eeb20c0 commit 7ba244b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ggml.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ typedef void * thread_ret_t;
195195
#define GGML_ALIGNED_FREE(ptr) _aligned_free(ptr)
196196
#else
197197
inline static void * ggml_aligned_malloc(size_t size) {
198-
void * aligned_memory = NULL;
199-
#ifdef GGML_USE_CPU_HBM
200198
if (size == 0) {
201-
GGML_PRINT("WARNING: Behavior may be unexpected when allocate 0 byte for hbw_posix_memalign!");
199+
GGML_PRINT("WARNING: Behavior may be unexpected when allocate 0 byte for ggml_aligned_malloc!");
202200
return NULL;
203201
}
202+
void * aligned_memory = NULL;
203+
#ifdef GGML_USE_CPU_HBM
204204
int result = hbw_posix_memalign(&aligned_memory, 16, size);
205205
#elif GGML_USE_METAL
206206
int result = posix_memalign(&aligned_memory, sysconf(_SC_PAGESIZE), size);

0 commit comments

Comments
 (0)