RPA Toolkit
Work on rmap_t
authorMartin Stoilov <martin@rpasearch.com>
Mon, 6 Jun 2011 06:57:02 +0000 (23:57 -0700)
committerMartin Stoilov <martin@rpasearch.com>
Mon, 6 Jun 2011 06:57:02 +0000 (23:57 -0700)
rlib/rhash.c
rlib/rhash.h
rlib/rmap.c
rlib/rmap.h

index fad43ee..011dc24 100644 (file)
@@ -115,6 +115,12 @@ rhash_t *r_hash_create(ruint nbits, r_hash_equalfunc eqfunc, r_hash_hashfun hfun
 }
 
 
+void r_hash_destroy(rhash_t* hash)
+{
+       r_object_destroy((robject_t*)hash);
+}
+
+
 robject_t *r_hash_init(robject_t *obj, ruint32 type, r_object_cleanupfun cleanup, r_object_copyfun copy,
                                                ruint nbits, r_hash_equalfunc eqfunc, r_hash_hashfun hfunc)
 {
index 042011f..1b0b906 100644 (file)
@@ -30,6 +30,7 @@ struct rhash_s {
 #define r_hash_size(__h__) (1 << (__h__)->nbits)
 #define r_hash_mask(__h__) (r_hash_size(__h__) - 1)
 rhash_t *r_hash_create(ruint nbits, r_hash_equalfunc eqfunc, r_hash_hashfun hfunc);
+void r_hash_destroy(rhash_t* hash);
 robject_t *r_hash_init(robject_t *obj, ruint32 type, r_object_cleanupfun cleanup, r_object_copyfun copy,
                                                ruint nbits, r_hash_equalfunc eqfunc, r_hash_hashfun hfunc);
 
index 67895a2..85d59cd 100644 (file)
@@ -3,14 +3,48 @@
 #include "rmem.h"
 
 
+typedef struct rmap_node_s {
+       rstr_t key;
+       rpointer value;
+       rlink_t active;
+       rlink_t hash;
+} rmap_node_t;
+
+
+robject_t *r_map_copy(const robject_t *obj)
+{
+       return (robject_t*)NULL;
+}
+
+
+void r_map_cleanup(robject_t *obj)
+{
+       rmap_t *map = (rmap_t*)obj;
+       r_carray_destroy(map->members);
+       r_hash_destroy(map->hash);
+       r_object_cleanup(&map->obj);
+}
+
+
+robject_t *r_map_init(robject_t *obj, ruint32 type, r_object_cleanupfun cleanup, r_object_copyfun copy, ruint elt_size)
+{
+       rmap_t *map = (rmap_t*)obj;
+       r_object_init(obj, type, cleanup, copy);
+       map->hash = r_hash_create(5, r_hash_rstrequal, r_hash_rstrhash);
+       map->members = r_carray_create(elt_size);
+       r_list_init(&map->active);
+       r_list_init(&map->inactive);
+       return obj;
+}
+
 rmap_t *r_map_create(ruint elt_size)
 {
        return NULL;
 }
 
 
-void r_map_destroy(rmap_t *array)
+void r_map_destroy(rmap_t *map)
 {
-
+       r_object_destroy((robject_t*)map);
 }
 
index 80f2ab5..ec11da4 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "rcarray.h"
 #include "rhash.h"
+#include "rlist.h"
 #include "rstring.h"
 #include "robject.h"
 
@@ -13,9 +14,10 @@ extern "C" {
 
 typedef struct rmap_s {
        robject_t obj;
-       rcarray_t *members;
-       rarray_t *names;
        rhash_t *hash;
+       rcarray_t *members;
+       rlist_t active;
+       rlist_t inactive;
 } rmap_t;