2 ** Copyright (C) 2002 by Kevin L. Mitchell <klmitch@mit.edu>
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Library General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2 of the License, or (at your option) any later version.
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Library General Public License for more details.
14 ** You should have received a copy of the GNU Library General Public
15 ** License along with this library; if not, write to the Free
16 ** Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24 #include "dbprim_int.h"
28 /** \ingroup dbprim_hash
29 * \brief Free memory used by an empty hash table.
31 * This function releases the memory used by the bucket table in an
34 * \param table A pointer to a #hash_table_t.
36 * \retval DB_ERR_BADARGS An invalid argument was given.
37 * \retval DB_ERR_FROZEN The table is frozen.
38 * \retval DB_ERR_NOTEMPTY The table is not empty.
41 ht_free(hash_table_t *table)
43 initialize_dbpr_error_table(); /* initialize error table */
45 if (!ht_verify(table)) /* verify argument */
46 return DB_ERR_BADARGS;
48 if (table->ht_flags & HASH_FLAG_FREEZE) /* don't free from frozen tables */
51 if (table->ht_count) /* make sure the table's empty */
52 return DB_ERR_NOTEMPTY;
54 if (!table->ht_modulus && !table->ht_table) /* short-circuit */
57 free(table->ht_table); /* free allocated memory */
59 table->ht_modulus = 0; /* zero the table and modulus */