summaryrefslogtreecommitdiffhomepage
path: root/ir/adt
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-09-07 10:40:53 +0200
committerMatthias Braun <matze@braunis.de>2015-09-07 19:58:32 +0200
commit7f02707a2e48a5a461a28e831dae9bdf852b6e1d (patch)
tree0a019b011690760b54ea230b48220f8a61e23d01 /ir/adt
parent41057476683b57136af9f56fd62d544cf5ad51e2 (diff)
pmap: Cleanup
Diffstat (limited to 'ir/adt')
-rw-r--r--ir/adt/pmap.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/ir/adt/pmap.c b/ir/adt/pmap.c
index c078ecd..75d4ac6 100644
--- a/ir/adt/pmap.c
+++ b/ir/adt/pmap.c
@@ -10,33 +10,27 @@
* @date 09.06.2002
*/
#include "pmap.h"
+
#include "set.h"
#include "hashptr.h"
-
-struct pmap {
- int dummy; /* dummy entry */
-};
-
-
#define INITIAL_SLOTS 64
/** map a pmap into a set */
-#define M2S(map) (set *)(map)
+#define M2S(map) (set*)(map)
/**
* compare the keys of two entry pairs
*/
-static int pmap_entry_cmp(const void *p1, const void *p2, size_t size)
+static int pmap_entry_cmp(void const *p1, void const *p2, size_t size)
{
- const pmap_entry *entry1 = (const pmap_entry*) p1;
- const pmap_entry *entry2 = (const pmap_entry*) p2;
- (void) size;
+ const pmap_entry *entry1 = (const pmap_entry*)p1;
+ const pmap_entry *entry2 = (const pmap_entry*)p2;
+ (void)size;
return entry1->key != entry2->key;
}
-/* Creates a new empty map with an initial number of slots. */
pmap *pmap_create_ex(size_t slots)
{
return (pmap *)new_set(pmap_entry_cmp, slots);
@@ -61,25 +55,25 @@ void pmap_insert(pmap *map, const void *key, void *value)
p->value = value;
}
-int pmap_contains(pmap *map, const void *key)
+int pmap_contains(pmap const *map, const void *key)
{
return pmap_find(map, key) != NULL;
}
-pmap_entry * pmap_find(pmap *map, const void *key)
+pmap_entry *pmap_find(pmap const *map, const void *key)
{
pmap_entry const entry = { key, 0 };
return set_find(pmap_entry, M2S(map), &entry, sizeof(entry), hash_ptr(key));
}
-void * (pmap_get)(pmap *map, const void *key)
+void *(pmap_get)(pmap const *map, const void *key)
{
pmap_entry * entry = pmap_find(map, key);
return entry == NULL ? NULL : entry->value;
}
-size_t pmap_count(pmap *map)
+size_t pmap_count(pmap const *map)
{
return set_count(M2S(map));
}