summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-11-27 14:21:19 -0800
committerJoshua Haberman <joshua@reverberate.org>2009-11-27 14:21:19 -0800
commitd16038073629b3f89acabfbd2f2d9911b2a771d4 (patch)
tree18f8264074541e373c8d393ea933f2b4b4a5f87b /src
parent6191fe3ae2fee99948da11d9834fe6425cf32037 (diff)
Update upbc to use self-describing upb_msg instead of void*.
Diffstat (limited to 'src')
-rw-r--r--src/upb_context.c4
-rw-r--r--src/upb_context.h6
-rw-r--r--src/upb_def.c3
3 files changed, 7 insertions, 6 deletions
diff --git a/src/upb_context.c b/src/upb_context.c
index f30c6da..6772280 100644
--- a/src/upb_context.c
+++ b/src/upb_context.c
@@ -44,7 +44,7 @@ struct upb_context *upb_context_new()
struct upb_string name = UPB_STRLIT("google.protobuf.FileDescriptorSet");
struct upb_symtab_entry *e = upb_strtable_lookup(&c->psymtab, &name);
assert(e);
- c->fds_msg = e->ref.msg;
+ c->fds_msgdef = e->ref.msg;
c->fds_size = 16;
c->fds_len = 0;
c->fds = malloc(sizeof(*c->fds));
@@ -349,7 +349,7 @@ void upb_context_addfds(struct upb_context *c,
void upb_context_parsefds(struct upb_context *c, struct upb_string *fds_str,
struct upb_status *status)
{
- struct upb_msg *fds = upb_msg_new(c->fds_msg);
+ struct upb_msg *fds = upb_msg_new(c->fds_msgdef);
upb_msg_parsestr(fds, fds_str->ptr, fds_str->byte_len, status);
if(!upb_ok(status)) return;
upb_context_addfds(c, (google_protobuf_FileDescriptorSet*)fds, status);
diff --git a/src/upb_context.h b/src/upb_context.h
index b223b40..77c2db8 100644
--- a/src/upb_context.h
+++ b/src/upb_context.h
@@ -41,9 +41,9 @@ struct upb_symtab_entry {
struct upb_context {
upb_atomic_refcount_t refcount;
upb_rwlock_t lock;
- struct upb_strtable symtab; /* The context's symbol table. */
- struct upb_strtable psymtab; /* Private symbols, for internal use. */
- struct upb_msgdef *fds_msg; /* In psymtab, ptr here for convenience. */
+ struct upb_strtable symtab; /* The context's symbol table. */
+ struct upb_strtable psymtab; /* Private symbols, for internal use. */
+ struct upb_msgdef *fds_msgdef; /* In psymtab, ptr here for convenience. */
/* A list of the FileDescriptorProtos we own (from having parsed them
* ourselves) and must free on destruction. */
diff --git a/src/upb_def.c b/src/upb_def.c
index 4484055..49d5f21 100644
--- a/src/upb_def.c
+++ b/src/upb_def.c
@@ -110,7 +110,8 @@ void _upb_msgdef_free(struct upb_msgdef *m)
for (unsigned int i = 0; i < m->num_fields; i++) {
struct upb_fielddef *f = &m->fields[i];
upb_string_unref(f->name);
- upb_def_unref(f->ref, f->type);
+ if (upb_issubmsg(f) || f->type == UPB_TYPENUM(ENUM))
+ upb_def_unref(f->ref, f->type);
}
free(m->fields);
free(m);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback