1 //
2 //      aegis - project change supervisor
3 //      Copyright (C) 1990-1995, 2002-2006, 2008, 2012 Peter Miller
4 //
5 //      This program is free software; you can redistribute it and/or modify
6 //      it under the terms of the GNU General Public License as published by
7 //      the Free Software Foundation; either version 3 of the License, or
8 //      (at your option) any later version.
9 //
10 //      This program is distributed in the hope that it will be useful,
11 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //      GNU General Public License for more details.
14 //
15 //      You should have received a copy of the GNU General Public License
16 //      along with this program. If not, see
17 //      <http://www.gnu.org/licenses/>.
18 //
19 
20 #include <common/mem.h>
21 #include <common/symtab.h>
22 #include <common/trace.h>
23 
24 
symtab_ty(int suggested_size)25 symtab_ty::symtab_ty(int suggested_size) :
26     reap(0),
27     hash_table(0),
28     hash_modulus(0),
29     hash_mask(0),
30     hash_load(0)
31 {
32     trace(("symtab(%d)\n{\n", suggested_size));
33     trace(("this = %p\n", this));
34     hash_modulus = 1 << 5; // MUST be a power of 2
35     while ((long)hash_modulus < (long)suggested_size)
36         hash_modulus <<= 1;
37     hash_mask = hash_modulus - 1;
38     hash_table = new row_t * [hash_modulus];
39     for (str_hash_ty j = 0; j < hash_modulus; ++j)
40         hash_table[j] = 0;
41     trace(("}\n"));
42 }
43 
44 
~symtab_ty()45 symtab_ty::~symtab_ty()
46 {
47     trace(("~symtab()\n{\n"));
48     trace(("this = %p\n", this));
49     clear();
50 
51     reap = 0;
52     delete [] hash_table;
53     hash_table = 0;
54     hash_modulus = 0;
55     hash_mask = 0;
56     trace(("}\n"));
57 }
58 
59 
60 // vim: set ts=8 sw=4 et :
61