mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-28091 fixup: Fix another pfs_malloc() stub
In commit 0f56e21efa
only one pfs_malloc() stub was fixed to return aligned memory.
Also, the MSVC _aligned_malloc() pairs with _aligned_free().
This commit is contained in:
@@ -23,12 +23,25 @@
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include <pfs_global.h>
|
||||
#ifdef HAVE_MEMALIGN
|
||||
# include <malloc.h>
|
||||
#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)
|
||||
|
Reference in New Issue
Block a user