summaryrefslogtreecommitdiff
path: root/mysys/hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'mysys/hash.c')
-rw-r--r--mysys/hash.c26
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 */
/*