summaryrefslogtreecommitdiff
path: root/upb
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2018-12-31 20:02:56 -0800
committerJoshua Haberman <jhaberman@gmail.com>2018-12-31 20:02:56 -0800
commitdaa9175dd4bc8625049be4b1fbab9f64d1153bdd (patch)
tree897264cc48ea50d1c8d5e0ccfcd54941475491ca /upb
parentd0c8bb84f449e7fc94a85ac1594cb8090f3c9bb8 (diff)
parent0ce9b818153088704a2206635c08574f60df45f1 (diff)
Merge branch 'arrayapi' into defcleanup
Diffstat (limited to 'upb')
-rw-r--r--upb/generated_util.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/upb/generated_util.h b/upb/generated_util.h
index 3907483..3989f1e 100644
--- a/upb/generated_util.h
+++ b/upb/generated_util.h
@@ -31,7 +31,7 @@ UPB_INLINE void *_upb_array_mutable_accessor(void *msg, size_t ofs,
if (size) *size = arr->len;
return arr->data;
} else {
- if (size) size = 0;
+ if (size) *size = 0;
return NULL;
}
}
@@ -47,6 +47,7 @@ UPB_INLINE void *_upb_array_resize_accessor(void *msg, size_t ofs, size_t size,
if (!arr) {
arr = upb_array_new(type, arena);
if (!arr) return NULL;
+ *PTR_AT(msg, ofs, upb_array*) = arr;
}
if (size > arr->size) {
@@ -73,7 +74,7 @@ UPB_INLINE bool _upb_array_append_accessor(void *msg, size_t ofs,
const void *value,
upb_arena *arena) {
upb_array *arr = *PTR_AT(msg, ofs, upb_array*);
- size_t i = arr ? arr->len : 1;
+ size_t i = arr ? arr->len : 0;
void *data =
_upb_array_resize_accessor(msg, ofs, i + 1, elem_size, type, arena);
if (!data) return false;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback