summaryrefslogtreecommitdiff
path: root/ext/mysql/libmysql/my_alloc.c
diff options
context:
space:
mode:
authorMySQL Team <mysql@php.net>2001-01-23 16:48:50 +0000
committerMySQL Team <mysql@php.net>2001-01-23 16:48:50 +0000
commit800f555b707c696798877c80352ded46289e87c4 (patch)
treec540242b6e6da4e9b99b46797a26b215abef0a64 /ext/mysql/libmysql/my_alloc.c
parentd36858681a0d48414702524ebd16f31289b06fa8 (diff)
downloadphp-git-800f555b707c696798877c80352ded46289e87c4.tar.gz
Upgrade ext/mysql/libmysql to version 3.23.32. One notable bug fix is
that the client can now connect to a server which is using a default charset other than latin1.
Diffstat (limited to 'ext/mysql/libmysql/my_alloc.c')
-rw-r--r--ext/mysql/libmysql/my_alloc.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/ext/mysql/libmysql/my_alloc.c b/ext/mysql/libmysql/my_alloc.c
index 5ac2d69ffd..01992b64dd 100644
--- a/ext/mysql/libmysql/my_alloc.c
+++ b/ext/mysql/libmysql/my_alloc.c
@@ -7,12 +7,25 @@ This file is public domain and comes with NO WARRANTY of any kind */
#include <my_sys.h>
#include <m_string.h>
-void init_alloc_root(MEM_ROOT *mem_root,uint block_size)
+void init_alloc_root(MEM_ROOT *mem_root, uint block_size, uint pre_alloc_size)
{
mem_root->free=mem_root->used=0;
mem_root->min_malloc=16;
mem_root->block_size=block_size-MALLOC_OVERHEAD-sizeof(USED_MEM)-8;
mem_root->error_handler=0;
+#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG))
+ if (pre_alloc_size)
+ {
+ if ((mem_root->free = mem_root->pre_alloc=
+ (USED_MEM*) my_malloc(pre_alloc_size+ ALIGN_SIZE(sizeof(USED_MEM)),
+ MYF(0))))
+ {
+ mem_root->free->size=pre_alloc_size+ALIGN_SIZE(sizeof(USED_MEM));
+ mem_root->free->left=pre_alloc_size;
+ mem_root->free->next=0;
+ }
+ }
+#endif
}
gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
@@ -75,27 +88,39 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size)
/* deallocate everything used by alloc_root */
-void free_root(MEM_ROOT *root)
+void free_root(MEM_ROOT *root, myf MyFlags)
{
reg1 USED_MEM *next,*old;
DBUG_ENTER("free_root");
if (!root)
DBUG_VOID_RETURN; /* purecov: inspected */
- for (next= root->used ; next ; )
+ if (!(MyFlags & MY_KEEP_PREALLOC))
+ root->pre_alloc=0;
+
+ for ( next=root->used; next ;)
{
old=next; next= next->next ;
- my_free((gptr) old,MYF(0));
+ if (old != root->pre_alloc)
+ my_free((gptr) old,MYF(0));
}
for (next= root->free ; next ; )
{
old=next; next= next->next ;
- my_free((gptr) old,MYF(0));
+ if (old != root->pre_alloc)
+ my_free((gptr) old,MYF(0));
}
root->used=root->free=0;
+ if (root->pre_alloc)
+ {
+ root->free=root->pre_alloc;
+ root->free->left=root->pre_alloc->size-ALIGN_SIZE(sizeof(USED_MEM));
+ root->free->next=0;
+ }
DBUG_VOID_RETURN;
}
+
char *strdup_root(MEM_ROOT *root,const char *str)
{
uint len= (uint) strlen(str)+1;