diff options
author | konstantin@mysql.com <> | 2004-09-22 15:50:07 +0400 |
---|---|---|
committer | konstantin@mysql.com <> | 2004-09-22 15:50:07 +0400 |
commit | 36548b10ca2d796c46436ab445569f6e0476ecaf (patch) | |
tree | e9e451c78db8c48bfcfbf6943d785f85d1b8a6f8 /mysys | |
parent | e7a70ed162f6b208ead1fa93824592f242b015bc (diff) | |
download | mariadb-git-36548b10ca2d796c46436ab445569f6e0476ecaf.tar.gz |
A fix and test case for Bug#5315 "mysql_change_user() doesn't free
prepared statements."
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/hash.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mysys/hash.c b/mysys/hash.c index ce25ae89b63..6f2788ddce7 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -88,6 +88,32 @@ void hash_free(HASH *hash) DBUG_VOID_RETURN; } + +/* + Delete all elements from the hash (the hash itself is to be reused). + + SYNOPSIS + hash_reset() + hash the hash to delete elements of +*/ + +void hash_reset(HASH *hash) +{ + DBUG_ENTER("hash_reset"); + if (hash->free) + { + HASH_LINK *link= dynamic_element(&hash->array, 0, HASH_LINK*); + HASH_LINK *end= link + hash->records; + for (; link < end; ++link) + (*hash->free)(link->data); + } + reset_dynamic(&hash->array); + hash->records= 0; + hash->blength= 1; + hash->current_record= NO_RECORD; + DBUG_VOID_RETURN; +} + /* some helper functions */ /* |