fix a bunch of warnings reported by clang analyzer
[libfirm] / ir / adt / cpset.c
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Custom pointer set
23  * @author  Matthias Braun
24  *
25  * This implements a set of pointers which allows to specify custom callbacks
26  * for comparing and hashing its elements.
27  */
28 #include "config.h"
29
30 #include "cpset.h"
31
32 #define HashSet                   cpset_t
33 #define HashSetIterator           cpset_iterator_t
34 #define HashSetEntry              cpset_hashset_entry_t
35 #define ValueType                 void*
36 #define NullValue                 NULL
37 #define DeletedValue              ((void*)-1)
38 #define Hash(this,key)            this->hash_function(key)
39 #define KeysEqual(this,key1,key2) this->cmp_function(key1, key2)
40 #define SCALAR_RETURN
41 #define SetRangeEmpty(ptr,size)   memset(ptr, 0, (size) * sizeof(cpset_hashset_entry_t))
42
43 void cpset_init_(cpset_t *self);
44 #define hashset_init            cpset_init_
45 void cpset_init_size_(cpset_t *self, size_t expected_elems);
46 #define hashset_init_size       cpset_init_size_
47 #define hashset_destroy         cpset_destroy
48 #define hashset_insert          cpset_insert
49 #define hashset_remove          cpset_remove
50 #define hashset_find            cpset_find
51 #define hashset_size            cpset_size
52 #define hashset_iterator_init   cpset_iterator_init
53 #define hashset_iterator_next   cpset_iterator_next
54 #define hashset_remove_iterator cpset_remove_iterator
55
56 #include "hashset.c.inl"
57
58 void cpset_init(cpset_t *this_, cpset_hash_function hash_function,
59                 cpset_cmp_function cmp_function)
60 {
61         this_->hash_function = hash_function;
62         this_->cmp_function = cmp_function;
63         cpset_init_(this_);
64 }
65
66 void cpset_init_size(cpset_t *this_, cpset_hash_function hash_function,
67                      cpset_cmp_function cmp_function, size_t expected_elems)
68 {
69         this_->hash_function = hash_function;
70         this_->cmp_function = cmp_function;
71         cpset_init_size_(this_, expected_elems);
72 }