summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2023-03-06 13:37:12 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2023-03-06 13:37:12 +0200
commit669a0c6efb89cd5df4eb117c9c44694a9fbeb52c (patch)
tree93af8832773ce9f91db2c961bb2d2f4d49d3b027 /mysys
parent550b8d76b3be360b1c7984a2531e094cd4c37f8c (diff)
parent25c048066a9557d1aa506220316c6fa57be5da91 (diff)
downloadmariadb-git-669a0c6efb89cd5df4eb117c9c44694a9fbeb52c.tar.gz
Merge 10.6 into 10.8
Diffstat (limited to 'mysys')
-rw-r--r--mysys/mulalloc.c19
-rw-r--r--mysys/my_alloc.c12
2 files changed, 31 insertions, 0 deletions
diff --git a/mysys/mulalloc.c b/mysys/mulalloc.c
index 357f9315f2b..51f8d61b574 100644
--- a/mysys/mulalloc.c
+++ b/mysys/mulalloc.c
@@ -17,6 +17,11 @@
#include "mysys_priv.h"
#include <stdarg.h>
+#ifndef DBUG_OFF
+/* Put a protected barrier after every element when using my_multi_malloc() */
+#define ALLOC_BARRIER
+#endif
+
/*
Malloc many pointers at the same time
Only ptr1 can be free'd, and doing this will free all
@@ -45,6 +50,9 @@ void* my_multi_malloc(PSI_memory_key key, myf myFlags, ...)
{
length=va_arg(args,uint);
tot_length+=ALIGN_SIZE(length);
+#ifdef ALLOC_BARRIER
+ tot_length+= ALIGN_SIZE(1);
+#endif
}
va_end(args);
@@ -58,6 +66,10 @@ void* my_multi_malloc(PSI_memory_key key, myf myFlags, ...)
*ptr=res;
length=va_arg(args,uint);
res+=ALIGN_SIZE(length);
+#ifdef ALLOC_BARRIER
+ TRASH_FREE(res, ALIGN_SIZE(1));
+ res+= ALIGN_SIZE(1);
+#endif
}
va_end(args);
DBUG_RETURN((void*) start);
@@ -89,6 +101,9 @@ void *my_multi_malloc_large(PSI_memory_key key, myf myFlags, ...)
{
length=va_arg(args,ulonglong);
tot_length+=ALIGN_SIZE(length);
+#ifdef ALLOC_BARRIER
+ tot_length+= ALIGN_SIZE(1);
+#endif
}
va_end(args);
@@ -102,6 +117,10 @@ void *my_multi_malloc_large(PSI_memory_key key, myf myFlags, ...)
*ptr=res;
length=va_arg(args,ulonglong);
res+=ALIGN_SIZE(length);
+#ifdef ALLOC_BARRIER
+ TRASH_FREE(res, ALIGN_SIZE(1));
+ res+= ALIGN_SIZE(1);
+#endif
}
va_end(args);
DBUG_RETURN((void*) start);
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index a5b855f9604..43f26751f27 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -28,6 +28,11 @@
#undef EXTRA_DEBUG
#define EXTRA_DEBUG
+#ifndef DBUG_OFF
+/* Put a protected barrier after every element when using multi_alloc_root() */
+#define ALLOC_BARRIER
+#endif
+
/* data packed in MEM_ROOT -> min_malloc */
/* Don't allocate too small blocks */
@@ -396,6 +401,9 @@ void *multi_alloc_root(MEM_ROOT *root, ...)
{
length= va_arg(args, uint);
tot_length+= ALIGN_SIZE(length);
+#ifdef ALLOC_BARRIER
+ tot_length+= ALIGN_SIZE(1);
+#endif
}
va_end(args);
@@ -409,6 +417,10 @@ void *multi_alloc_root(MEM_ROOT *root, ...)
*ptr= res;
length= va_arg(args, uint);
res+= ALIGN_SIZE(length);
+#ifdef ALLOC_BARRIER
+ TRASH_FREE(res, ALIGN_SIZE(1));
+ res+= ALIGN_SIZE(1);
+#endif
}
va_end(args);
DBUG_RETURN((void*) start);