diff --git a/storage/perfschema/unittest/stub_pfs_global.h b/storage/perfschema/unittest/stub_pfs_global.h index 48a01ce5be2..22a87430e33 100644 --- a/storage/perfschema/unittest/stub_pfs_global.h +++ b/storage/perfschema/unittest/stub_pfs_global.h @@ -67,8 +67,11 @@ void *pfs_malloc(PFS_builtin_memory_class *klass, size_t size, myf) void pfs_free(PFS_builtin_memory_class *, size_t, void *ptr) { - if (ptr != NULL) - free(ptr); +#ifdef HAVE_ALIGNED_MALLOC + _aligned_free(ptr); +#else + free(ptr); +#endif } void *pfs_malloc_array(PFS_builtin_memory_class *klass, size_t n, size_t size, myf flags) diff --git a/storage/perfschema/unittest/stub_print_error.h b/storage/perfschema/unittest/stub_print_error.h index a02e2478d27..026ac905569 100644 --- a/storage/perfschema/unittest/stub_print_error.h +++ b/storage/perfschema/unittest/stub_print_error.h @@ -23,12 +23,25 @@ #include #include #include +#ifdef HAVE_MEMALIGN +# include +#endif bool pfs_initialized= false; void *pfs_malloc(PFS_builtin_memory_class *klass, size_t size, myf flags) { +#ifndef PFS_ALIGNEMENT void *ptr= malloc(size); +#elif defined HAVE_MEMALIGN + void *ptr= memalign(PFS_ALIGNEMENT, size); +#elif defined HAVE_ALIGNED_MALLOC + void *ptr= _aligned_malloc(size, PFS_ALIGNEMENT); +#else + void *ptr; + if (posix_memalign(&ptr, PFS_ALIGNEMENT, size)) + ptr= NULL; +#endif if (ptr && (flags & MY_ZEROFILL)) memset(ptr, 0, size); return ptr; @@ -36,8 +49,11 @@ void *pfs_malloc(PFS_builtin_memory_class *klass, size_t size, myf flags) void pfs_free(PFS_builtin_memory_class *, size_t, void *ptr) { - if (ptr != NULL) - free(ptr); +#ifdef HAVE_ALIGNED_MALLOC + _aligned_free(ptr); +#else + free(ptr); +#endif } void *pfs_malloc_array(PFS_builtin_memory_class *klass, size_t n, size_t size, myf flags)