summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/hashmap.h
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2013-03-04 21:27:36 +0100
committerMichael Stapelberg <michael@stapelberg.de>2013-03-04 21:27:36 +0100
commit04b08da9af0c450d645ab7389d1467308cfc2db8 (patch)
treedb247935fa4f2f94408edc3acd5d0d4f997aa0d8 /src/pkg/runtime/hashmap.h
parent917c5fb8ec48e22459d77e3849e6d388f93d3260 (diff)
downloadgolang-upstream/1.1_hg20130304.tar.gz
Imported Upstream version 1.1~hg20130304upstream/1.1_hg20130304
Diffstat (limited to 'src/pkg/runtime/hashmap.h')
-rw-r--r--src/pkg/runtime/hashmap.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/pkg/runtime/hashmap.h b/src/pkg/runtime/hashmap.h
index 4c10cf6ef..9b82f299e 100644
--- a/src/pkg/runtime/hashmap.h
+++ b/src/pkg/runtime/hashmap.h
@@ -63,7 +63,6 @@
}
*/
-#define malloc runtime·mal
#define memset(a,b,c) runtime·memclr((byte*)(a), (uint32)(c))
#define memcpy(a,b,c) runtime·memmove((byte*)(a),(byte*)(b),(uint32)(c))
#define assert(a) if(!(a)) runtime·throw("hashmap assert")
@@ -143,7 +142,7 @@ struct hash_iter {
Remove all sub-tables associated with *h.
This undoes the effects of hash_init().
If other memory pointed to by user data must be freed, the caller is
- responsible for doiing do by iterating over *h first; see
+ responsible for doing so by iterating over *h first; see
hash_iter_init()/hash_next(). */
// void hash_destroy (struct hash *h);
@@ -152,7 +151,7 @@ struct hash_iter {
/* Initialize *it from *h. */
// void hash_iter_init (struct hash *h, struct hash_iter *it);
-/* Return the next used entry in the table which which *it was initialized. */
+/* Return the next used entry in the table with which *it was initialized. */
// void *hash_next (struct hash_iter *it);
/*---- test interface ----*/
@@ -160,3 +159,27 @@ struct hash_iter {
whether used or not. "level" is the subtable level, 0 means first level. */
/* TESTING ONLY: DO NOT USE THIS ROUTINE IN NORMAL CODE */
// void hash_visit (struct hash *h, void (*data_visit) (void *arg, int32 level, void *data), void *arg);
+
+/* Used by the garbage collector */
+struct hash_gciter
+{
+ int32 elemsize;
+ uint8 flag;
+ uint8 valoff;
+ uint32 i; /* stack pointer in subtable_state */
+ struct hash_subtable *st;
+ struct hash_gciter_sub {
+ struct hash_entry *e; /* pointer into subtable */
+ struct hash_entry *last; /* last entry in subtable */
+ } subtable_state[4];
+};
+struct hash_gciter_data
+{
+ struct hash_subtable *st; /* subtable pointer, or nil */
+ uint8 *key_data; /* key data, or nil */
+ uint8 *val_data; /* value data, or nil */
+ bool indirectkey; /* storing pointers to keys */
+ bool indirectval; /* storing pointers to values */
+};
+bool hash_gciter_init (struct Hmap *h, struct hash_gciter *it);
+bool hash_gciter_next (struct hash_gciter *it, struct hash_gciter_data *data);