used new new_type_frame() to generate frame types
[libfirm] / ir / adt / pmap.c
index 89bbda9..019ebad 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <assert.h>
 #include "set.h"
+#include "hashptr.h"
 
 
 struct pmap {
@@ -22,25 +23,28 @@ struct pmap {
 };
 
 
-static const int INITIAL_SLOTS = 64;
+#define INITIAL_SLOTS 64
 
 
-static int pmap_entry_cmp(const pmap_entry * entry1, const pmap_entry * entry2, size_t size) {
-  return entry1->key == entry2->key ? 0 : 1;
+static int pmap_entry_cmp(const void *p1, const void *p2, size_t size) {
+  const pmap_entry *entry1 = p1;
+  const pmap_entry *entry2 = p2;
+
+  return entry1->key != entry2->key;
 }
 
 
-pmap * pmap_create(void) {
-  return (pmap *) new_set((set_cmp_fun) pmap_entry_cmp, INITIAL_SLOTS);
+pmap *pmap_create(void) {
+  return (pmap *)new_set(pmap_entry_cmp, INITIAL_SLOTS);
 }
 
 
-void pmap_destroy(pmap * map) {
-  del_set((set *) map);
+void pmap_destroy(pmap *map) {
+  del_set((set *)map);
 }
 
 
-void pmap_insert(pmap * map, void * key, void * value) {
+void pmap_insert(pmap *map, void *key, void *value) {
   if (pmap_contains(map, key)) {
     pmap_entry * entry = pmap_find(map, key);
     entry->value = value;
@@ -48,32 +52,37 @@ void pmap_insert(pmap * map, void * key, void * value) {
     pmap_entry entry;
     entry.key = key;
     entry.value = value;
-    set_insert((set *) map, &entry, sizeof(pmap_entry), (unsigned) key);
+    set_insert((set *)map, &entry, sizeof(pmap_entry), HASH_PTR(key));
   }
 }
 
 
-bool pmap_contains(pmap * map, void * key) {
-  return set_find((set *) map, &key, sizeof(pmap_entry), (unsigned) key) != NULL;
+int pmap_contains(pmap *map, void *key) {
+  return set_find((set *)map, &key, sizeof(pmap_entry), HASH_PTR(key)) != NULL;
 }
 
 
-pmap_entry * pmap_find(pmap * map, void * key) {
-  return (pmap_entry *) set_find((set *) map, &key, sizeof(pmap_entry), (unsigned) key);
+pmap_entry * pmap_find(pmap *map, void *key) {
+  return (pmap_entry *)set_find((set *)map, &key, sizeof(pmap_entry), HASH_PTR(key));
 }
 
 
-void * pmap_get(pmap * map, void * key) {
+void * pmap_get(pmap *map, void *key) {
   pmap_entry * entry = pmap_find(map, key);
   return entry == NULL ? NULL : entry->value;
 }
 
 
-pmap_entry * pmap_first(pmap * map) {
-  return (pmap_entry *) set_first((set *) map);
+pmap_entry *pmap_first(pmap *map) {
+  return (pmap_entry *) set_first((set *)map);
+}
+
+
+pmap_entry *pmap_next(pmap *map) {
+  return (pmap_entry *) set_next((set *)map);
 }
 
 
-pmap_entry * pmap_next(pmap * map) {
-  return (pmap_entry *) set_next((set *) map);
+void pmap_break(pmap *map) {
+  set_break((set *)map);
 }