diff options
Diffstat (limited to 'upb/msg.c')
-rw-r--r-- | upb/msg.c | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -13,9 +13,6 @@ /* Used when a message is not extendable. */ typedef struct { - /* TODO(haberman): use pointer tagging so we we are slim when known unknown - * fields are not present. */ - upb_arena *arena; char *unknown; size_t unknown_len; size_t unknown_size; @@ -49,10 +46,6 @@ static upb_msg_internal_withext *upb_msg_getinternalwithext( return VOIDPTR_AT(msg, -sizeof(upb_msg_internal_withext)); } -upb_arena *upb_msg_arena(const upb_msg *msg) { - return upb_msg_getinternal_const(msg)->arena; -} - upb_msg *upb_msg_new(const upb_msglayout *l, upb_arena *a) { upb_alloc *alloc = upb_arena_alloc(a); void *mem = upb_malloc(alloc, upb_msg_sizeof(l)); @@ -70,7 +63,6 @@ upb_msg *upb_msg_new(const upb_msglayout *l, upb_arena *a) { /* Initialize internal members. */ in = upb_msg_getinternal(msg); - in->arena = a; in->unknown = NULL; in->unknown_len = 0; in->unknown_size = 0; @@ -99,10 +91,11 @@ upb_array *upb_array_new(upb_fieldtype_t type, upb_arena *a) { return ret; } -void upb_msg_addunknown(upb_msg *msg, const char *data, size_t len) { - upb_msg_internal* in = upb_msg_getinternal(msg); +void upb_msg_addunknown(upb_msg *msg, const char *data, size_t len, + upb_arena *arena) { + upb_msg_internal *in = upb_msg_getinternal(msg); if (len > in->unknown_size - in->unknown_len) { - upb_alloc *alloc = upb_arena_alloc(in->arena); + upb_alloc *alloc = upb_arena_alloc(arena); size_t need = in->unknown_size + len; size_t newsize = UPB_MAX(in->unknown_size * 2, need); in->unknown = upb_realloc(alloc, in->unknown, in->unknown_size, newsize); |