diff options
author | sasha@mysql.sashanet.com <> | 2000-10-28 23:26:48 -0600 |
---|---|---|
committer | sasha@mysql.sashanet.com <> | 2000-10-28 23:26:48 -0600 |
commit | 96815f82a670f107a2e34595c4b8a9330e00e3ea (patch) | |
tree | d6984a4bdab21e43bace50514dc6578eafcae414 /mysys/safemalloc.c | |
parent | efeec3f2059f9c8deb8a17a1aca1dd6cc5f582e6 (diff) | |
download | mariadb-git-96815f82a670f107a2e34595c4b8a9330e00e3ea.tar.gz |
libmysql/libmysql.c
keep vio from being freed twice when we are low on memory
mysys/safemalloc.c
changes for --safemalloc-mem-limit
sql/mini_client.cc
keep vio from being freed twice
sql/mysqld.cc
changes for --safemalloc-mem-limit
sql/slave.cc
prevent closing connection twice
sql/sql_string.h
shrink() did not work right when my_realloc() failed
Diffstat (limited to 'mysys/safemalloc.c')
-rw-r--r-- | mysys/safemalloc.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index d715f69e38a..589ed1c457b 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -73,6 +73,10 @@ #include "my_static.h" #include "mysys_err.h" +#ifndef DBUG_OFF +ulonglong safemalloc_mem_limit = 0; +#endif + #define pNext tInt._pNext #define pPrev tInt._pPrev #define sFileName tInt._sFileName @@ -125,11 +129,18 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags) DBUG_ENTER("_mymalloc"); DBUG_PRINT("enter",("Size: %u",uSize)); + if (!sf_malloc_quick) (void) _sanity (sFile, uLine); - /* Allocate the physical memory */ - pTmp = (struct remember *) malloc ( +#ifndef DBUG_OFF + if(safemalloc_mem_limit && + uSize + lCurMemory > safemalloc_mem_limit) + pTmp = 0; + else +#endif + /* Allocate the physical memory */ + pTmp = (struct remember *) malloc ( sizeof (struct irem) /* remember data */ + sf_malloc_prehunc + uSize /* size requested */ |