From d541566a7bdf496f77fe9f08b74c258564216a57 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 13 Dec 2019 16:49:55 -0800 Subject: [PATCH] Moved upb_array_new() to upb/reflection.h where it belongs. --- upb/decode.c | 2 +- upb/msg.c | 4 ++-- upb/msg.h | 2 +- upb/reflection.c | 4 ++++ upb/reflection.h | 3 +++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/upb/decode.c b/upb/decode.c index 042045da2d..cb3e6753f6 100644 --- a/upb/decode.c +++ b/upb/decode.c @@ -220,7 +220,7 @@ static upb_array *upb_getorcreatearr(upb_decframe *frame, if (!arr) { upb_fieldtype_t type = desctype_to_fieldtype[field->descriptortype]; - arr = upb_array_new(frame->state->arena, type); + arr = _upb_array_new(frame->state->arena, type); CHK(arr); *(upb_array**)&frame->msg[field->offset] = arr; } diff --git a/upb/msg.c b/upb/msg.c index bd3d347d58..756c6b5cac 100644 --- a/upb/msg.c +++ b/upb/msg.c @@ -101,7 +101,7 @@ const char *upb_msg_getunknown(const upb_msg *msg, size_t *len) { /** upb_array *****************************************************************/ -upb_array *upb_array_new(upb_arena *a, upb_fieldtype_t type) { +upb_array *_upb_array_new(upb_arena *a, upb_fieldtype_t type) { upb_array *arr = upb_arena_malloc(a, sizeof(upb_array)); if (!arr) { @@ -141,7 +141,7 @@ void *_upb_array_resize_fallback(upb_array **arr_ptr, size_t size, upb_fieldtype_t type, upb_arena *arena) { upb_array *arr = *arr_ptr; if (!arr) { - arr = upb_array_new(arena, type); + arr = _upb_array_new(arena, type); if (!arr) return NULL; *arr_ptr = arr; } diff --git a/upb/msg.h b/upb/msg.h index 743625b7bd..b66730f11e 100644 --- a/upb/msg.h +++ b/upb/msg.h @@ -122,7 +122,7 @@ UPB_INLINE void *_upb_array_ptr(upb_array *arr) { } /* Creates a new array on the given arena. */ -upb_array *upb_array_new(upb_arena *a, upb_fieldtype_t type); +upb_array *_upb_array_new(upb_arena *a, upb_fieldtype_t type); /* Resizes the capacity of the array to be at least min_size. */ bool _upb_array_realloc(upb_array *arr, size_t min_size, upb_arena *arena); diff --git a/upb/reflection.c b/upb/reflection.c index c7242d51f9..0b45e61776 100644 --- a/upb/reflection.c +++ b/upb/reflection.c @@ -161,6 +161,10 @@ void upb_msg_set(upb_msg *msg, const upb_fielddef *f, upb_msgval val, /** upb_array *****************************************************************/ +upb_array *upb_array_new(upb_arena *a, upb_fieldtype_t type) { + return _upb_array_new(a, type); +} + size_t upb_array_size(const upb_array *arr) { return arr->len; } diff --git a/upb/reflection.h b/upb/reflection.h index f284925904..7caabcff1f 100644 --- a/upb/reflection.h +++ b/upb/reflection.h @@ -54,6 +54,9 @@ void upb_msg_clearfield(upb_msg *msg, const upb_fielddef *f); /** upb_array *****************************************************************/ +/* Creates a new array on the given arena that holds elements of this type. */ +upb_array *upb_array_new(upb_arena *a, upb_fieldtype_t type); + /* Returns the size of the array. */ size_t upb_array_size(const upb_array *arr);