mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 11:27:39 +02:00
MDEV-28091 PERFORMANCE_SCHEMA unit tests fail due to memory misalignment
Let us make the mocked-up pfs_malloc() return aligned memory, just like the actual implementation does.
This commit is contained in:
parent
57dbe8785d
commit
0f56e21efa
1 changed files with 14 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2022, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License, version 2.0,
|
||||
|
|
@ -24,6 +25,9 @@
|
|||
#include <my_sys.h>
|
||||
#include <pfs_global.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_MEMALIGN
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
|
||||
bool pfs_initialized= false;
|
||||
|
||||
|
|
@ -43,7 +47,17 @@ void *pfs_malloc(size_t size, myf)
|
|||
if (--stub_alloc_fails_after_count <= 0)
|
||||
return NULL;
|
||||
|
||||
#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 != NULL)
|
||||
memset(ptr, 0, size);
|
||||
return ptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue