summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-12-23 11:48:49 -0800
committerJoshua Haberman <joshua@reverberate.org>2009-12-23 11:48:49 -0800
commit602e093504dc07fec421df636d307654685892cb (patch)
tree73eb6bdb01b8800326a099395ed2a311ba293477 /src
parentf49f7f94c10de1ab39bd045e4ff6bb281541b51f (diff)
Core compiles, though with warnings, and is still incomplete.
Diffstat (limited to 'src')
-rw-r--r--src/upb_data.h3
-rw-r--r--src/upb_table.c8
2 files changed, 6 insertions, 5 deletions
diff --git a/src/upb_data.h b/src/upb_data.h
index 7b0a97b..48b5d9d 100644
--- a/src/upb_data.h
+++ b/src/upb_data.h
@@ -190,8 +190,8 @@ typedef struct {
} upb_refcounted_string;
typedef union {
- upb_string_common common;
upb_norefcount_string norefcount;
+ upb_string_common common;
upb_refcounted_string refcounted;
} upb_string;
@@ -303,6 +303,7 @@ upb_string *upb_strreadfile(const char *filename);
// Initialize with the given macro, which must resolve to a const char*. You
// must not dynamically allocate this type.
typedef upb_string upb_static_string;
+#define UPB_STRLIT_LEN(str, len) {0 | UPB_DATA_FROZEN, len, str}
#define UPB_STRLIT(str) {{{0 | UPB_DATA_FROZEN}, sizeof(str), str}}
// Allows using upb_strings in printf, ie:
diff --git a/src/upb_table.c b/src/upb_table.c
index e73c6f4..41252a2 100644
--- a/src/upb_table.c
+++ b/src/upb_table.c
@@ -50,19 +50,19 @@ void upb_inttable_free(struct upb_inttable *t) { upb_table_free(&t->t); }
void upb_strtable_free(struct upb_strtable *t) {
// Free refs from the strtable.
struct upb_strtable_entry *e = upb_strtable_begin(t);
- for(; e; e = upb_strtable_next(&m->ntof, e)) {
+ for(; e; e = upb_strtable_next(t, e)) {
upb_string_unref(e->key);
}
upb_table_free(&t->t);
}
-static uint32_t strtable_bucket(struct upb_strtable *t, struct upb_string *key)
+static uint32_t strtable_bucket(struct upb_strtable *t, upb_string *key)
{
- uint32_t hash = MurmurHash2(key->ptr, key->byte_len, 0);
+ uint32_t hash = MurmurHash2(upb_string_getrobuf(key), upb_strlen(key), 0);
return (hash & (upb_strtable_size(t)-1)) + 1;
}
-void *upb_strtable_lookup(struct upb_strtable *t, struct upb_string *key)
+void *upb_strtable_lookup(struct upb_strtable *t, upb_string *key)
{
uint32_t bucket = strtable_bucket(t, key);
struct upb_strtable_entry *e;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback