MDEV-23865 Create malloc function attribute

This commit is contained in:
Yasuhiro-gh 2023-04-27 20:37:18 +10:00 committed by Daniel Black
parent cee9b3b850
commit 26b96094ec
2 changed files with 6 additions and 0 deletions

View file

@ -156,6 +156,7 @@ program. The paths leading to call of cold functions within code are
marked as unlikely by the branch prediction mechanism. optimize a
rarely invoked function for size instead for speed. */
# define ATTRIBUTE_COLD __attribute__((cold))
# define ATTRIBUTE_MALLOC __attribute__((malloc))
#elif defined _MSC_VER
# define ATTRIBUTE_NORETURN __declspec(noreturn)
# define ATTRIBUTE_NOINLINE __declspec(noinline)
@ -168,6 +169,10 @@ rarely invoked function for size instead for speed. */
# define ATTRIBUTE_COLD /* empty */
#endif
#ifndef ATTRIBUTE_MALLOC
# define ATTRIBUTE_MALLOC
#endif
#include <my_attribute.h>
#endif /* MY_COMPILER_INCLUDED */

View file

@ -62,6 +62,7 @@ void set_malloc_size_cb(MALLOC_SIZE_CB func)
@return A pointer to the allocated memory block, or NULL on failure.
*/
ATTRIBUTE_MALLOC
void *my_malloc(PSI_memory_key key, size_t size, myf my_flags)
{
my_memory_header *mh;