diff options
author | pem@mysql.comhem.se <> | 2003-12-15 13:24:16 +0100 |
---|---|---|
committer | pem@mysql.comhem.se <> | 2003-12-15 13:24:16 +0100 |
commit | 45e5896363761e4f61ec51fcf933ba2ac78fa7e9 (patch) | |
tree | ee3864cf944f460799a4850e7c1fdad0461a4592 /sql/sp_cache.cc | |
parent | 07541b6abf0aab821019fd3f4c07d30598a7d96a (diff) | |
download | mariadb-git-45e5896363761e4f61ec51fcf933ba2ac78fa7e9.tar.gz |
Fixed various memory leaks.
Diffstat (limited to 'sql/sp_cache.cc')
-rw-r--r-- | sql/sp_cache.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index 7e9d5f92ef0..4fee49c2d81 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -92,11 +92,11 @@ sp_cache_lookup(sp_cache **cp, char *name, uint namelen) return c->lookup(name, namelen); } -sp_head * +bool sp_cache_remove(sp_cache **cp, char *name, uint namelen) { sp_cache *c= *cp; - sp_head *sp= NULL; + bool found= FALSE; if (c) { @@ -109,10 +109,10 @@ sp_cache_remove(sp_cache **cp, char *name, uint namelen) if (c->version < v) c->remove_all(); else - sp= c->remove(name, namelen); + found= c->remove(name, namelen); c->version= v+1; } - return sp; + return found; } @@ -123,6 +123,14 @@ hash_get_key_for_sp_head(const byte *ptr, uint *plen, return ((sp_head*)ptr)->name(plen); } +static void +hash_free_sp_head(void *p) +{ + sp_head *sp= (sp_head *)p; + + delete sp; +} + sp_cache::sp_cache() { init(); @@ -137,7 +145,7 @@ void sp_cache::init() { hash_init(&m_hashtable, system_charset_info, 0, 0, 0, - hash_get_key_for_sp_head, 0, 0); + hash_get_key_for_sp_head, hash_free_sp_head, 0); version= 0; } |