summaryrefslogtreecommitdiff
path: root/src/upb_def.c
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2011-02-13 17:27:32 -0800
committerJoshua Haberman <joshua@reverberate.org>2011-02-13 17:27:32 -0800
commit4dce5ab709f2fcad836a562f3902f2654fc584c4 (patch)
tree1b7f21efdc2f4bd3fef801722557e84d01fd525e /src/upb_def.c
parentddb74551f4faa1e2583b9ece0f2d5a6d6c0dc704 (diff)
Fix upbc and descriptorgen, and update descriptor.
Diffstat (limited to 'src/upb_def.c')
-rw-r--r--src/upb_def.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/upb_def.c b/src/upb_def.c
index 651afc1..7e962c8 100644
--- a/src/upb_def.c
+++ b/src/upb_def.c
@@ -6,8 +6,8 @@
#include <stdlib.h>
#include <stddef.h>
+#include "descriptor.c"
#include "descriptor_const.h"
-#include "descriptor.h"
#include "upb_def.h"
#define alignof(t) offsetof(struct { char c; t x; }, x)
@@ -218,8 +218,7 @@ static void upb_deflist_init(upb_deflist *l) {
}
static void upb_deflist_uninit(upb_deflist *l) {
- for(uint32_t i = 0; i < l->len; i++)
- if(l->defs[i]) upb_def_unref(l->defs[i]);
+ for(uint32_t i = 0; i < l->len; i++) upb_def_unref(l->defs[i]);
free(l->defs);
}
@@ -759,6 +758,7 @@ static upb_flow_t upb_msgdef_value(void *_b, upb_fielddef *f, upb_value val) {
upb_defbuilder *b = _b;
switch(f->number) {
case GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_FIELDNUM: {
+ assert(val.type == UPB_TYPE(STRING));
upb_msgdef *m = upb_defbuilder_top(b);
upb_string_unref(m->base.fqname);
m->base.fqname = upb_string_getref(upb_value_getstr(val));
@@ -788,7 +788,6 @@ static upb_flow_t upb_msgdef_startsubmsg(void *_b, upb_fielddef *f,
case GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_FIELDNUM:
upb_enumdef_register_EnumDescriptorProto(b, h);
return UPB_DELEGATE;
- break;
default:
return UPB_SKIPSUBMSG;
}
@@ -1054,7 +1053,6 @@ err:
upb_def_unref(e->def);
}
upb_strtable_free(&tmptab);
- for (int i = 0; i < num_defs; i++) upb_def_unref(defs[i]);
return false;
}
@@ -1318,8 +1316,10 @@ void upb_symtab_add_descriptorproto(upb_symtab *symtab) {
// For the moment we silently decline to perform the operation if the symbols
// already exist in the symtab. Revisit this when we have a better story
// about whether syms in a table can be replaced.
- if(symtab->fds_msgdef) upb_def_unref(UPB_UPCAST(symtab->fds_msgdef));
+ if(symtab->fds_msgdef) return;
+ static upb_string descriptor_str =
+ UPB_STATIC_STRING_ARRAY(descriptor_pb);
upb_baredecoder *decoder = upb_baredecoder_new(&descriptor_str);
upb_status status = UPB_STATUS_INIT;
upb_symtab_addfds(symtab, upb_baredecoder_src(decoder), &status);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback