Go to the documentation of this file.
31 #include "upb/port_def.inc"
59 if (!
internal)
return false;
60 internal->size =
size;
62 internal->ext_begin =
size;
63 in->internal =
internal;
64 }
else if (
in->internal->ext_begin -
in->internal->unknown_end < need) {
67 size_t ext_bytes =
in->internal->size -
in->internal->ext_begin;
68 size_t new_ext_begin =
new_size - ext_bytes;
71 if (!
internal)
return false;
74 char*
ptr = (
char*)
internal;
75 memmove(
ptr + new_ext_begin,
ptr +
internal->ext_begin, ext_bytes);
77 internal->ext_begin = new_ext_begin;
79 in->internal =
internal;
81 UPB_ASSERT(
in->internal->ext_begin -
in->internal->unknown_end >= need);
90 in->internal->unknown_end +=
len;
105 return (
char*)(
in->internal + 1);
116 *
count = (
in->internal->size -
in->internal->ext_begin) /
133 for (
size_t i = 0;
i <
n;
i++) {
145 if (!
in->internal)
return;
180 int elem_size_lg2 = arr->
data & 7;
181 size_t old_bytes = arr->
size << elem_size_lg2;
188 new_bytes =
new_size << elem_size_lg2;
205 if (!arr)
return NULL;
221 if (!arr)
return false;
223 size_t elems = arr->
len;
244 map->key_size = key_size;
245 map->val_size = value_size;
251 void* b_key,
size_t size) {
260 #define UPB_COMPARE_INTEGERS(a, b) ((a) < (b) ? -1 : ((a) == (b) ? 0 : 1))
295 size_t common_size =
UPB_MIN(
a.size,
b.size);
296 int cmp = memcmp(
a.data,
b.data, common_size);
301 #undef UPB_COMPARE_INTEGERS
306 sorted->
start = s->size;
308 sorted->
end = sorted->
start + map_size;
311 if (sorted->
end > s->cap) {
313 s->entries = realloc(s->entries, s->cap *
sizeof(*s->entries));
314 if (!s->entries)
return false;
317 s->size = sorted->
end;
323 for (; src <
end; src++) {
333 int (*compar)(
const void*,
const void*);
366 qsort(&s->entries[sorted->
start], map_size,
sizeof(*s->entries), compar);
377 #define EXTREG_KEY_SIZE (sizeof(upb_MiniTable*) + sizeof(uint32_t))
381 memcpy(
buf +
sizeof(
l), &fieldnum,
sizeof(fieldnum));
397 for (; e <
end; e++) {
401 upb_value_constptr(
ext),
r->arena)) {
424 return upb_value_getconstptr(
v);
size_t upb_Message_ExtensionCount(const upb_Message *msg)
@ kUpb_FieldType_SFixed64
const upb_Message_Extension * _upb_Message_Getext(const upb_Message *msg, const upb_MiniTable_Extension *e)
UPB_INLINE void * upb_Arena_Realloc(upb_Arena *a, void *ptr, size_t oldsize, size_t size)
static upb_Array * getorcreate_array(upb_Array **arr_ptr, int elem_size_lg2, upb_Arena *arena)
return memset(p, 0, total)
UPB_INLINE bool upb_tabent_isempty(const upb_tabent *e)
UPB_INLINE bool upb_strtable_init(upb_strtable *table, upb_ctype_t ctype)
UPB_INLINE size_t _upb_Map_Size(const upb_Map *map)
bool _upb_Array_Append_fallback(upb_Array **arr_ptr, const void *value, int elem_size_lg2, upb_Arena *arena)
UPB_INLINE upb_Message * _upb_Message_New_inl(const upb_MiniTable *l, upb_Arena *a)
static bool realloc_internal(upb_Message *msg, size_t need, upb_Arena *arena)
#define UPB_UNREACHABLE()
const char * upb_Message_GetUnknown(const upb_Message *msg, size_t *len)
upb_Message_Extension * _upb_Message_Getorcreateext(upb_Message *msg, const upb_MiniTable_Extension *e, upb_Arena *arena)
static int _upb_mapsorter_cmpi64(const void *_a, const void *_b)
UPB_INLINE upb_Message_Internal * upb_Message_Getinternal(upb_Message *msg)
@ kUpb_FieldType_SFixed32
bool _upb_extreg_add(upb_ExtensionRegistry *r, const upb_MiniTable_Extension **e, size_t count)
UPB_INLINE uintptr_t _upb_tag_arrptr(void *ptr, int elem_size_lg2)
UPB_INLINE int _upb_Log2CeilingSize(int x)
bool upb_strtable_lookup2(const upb_strtable *t, const char *key, size_t len, upb_value *v)
#define UPB_PTR_AT(msg, ofs, type)
bool _upb_mapsorter_pushmap(_upb_mapsorter *s, upb_FieldType key_type, const upb_Map *map, _upb_sortedmap *sorted)
grpc_core::ScopedArenaPtr arena
static const upb_Message_Internal * upb_Message_Getinternal_const(const upb_Message *msg)
UPB_INLINE void * _upb_array_ptr(upb_array *arr)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
#define UPB_PTRADD(ptr, ofs)
const upb_Message_Extension * _upb_Message_Getexts(const upb_Message *msg, size_t *count)
upb_Message * _upb_Message_New(const upb_MiniTable *l, upb_Arena *a)
#define UPB_COMPARE_INTEGERS(a, b)
static size_t upb_msg_sizeof(const upb_msglayout *l)
void _upb_Message_DiscardUnknown_shallow(upb_Message *msg)
static void _upb_mapsorter_getkeys(const void *_a, const void *_b, void *a_key, void *b_key, size_t size)
UPB_INLINE void * upb_Arena_Malloc(upb_Arena *a, size_t size)
unsigned __int64 uint64_t
bool _upb_Message_AddUnknown(upb_Message *msg, const char *data, size_t len, upb_Arena *arena)
upb_Map * _upb_Map_New(upb_Arena *a, size_t key_size, size_t value_size)
static int _upb_mapsorter_cmpu64(const void *_a, const void *_b)
void qsort(void *a, size_t n, size_t es, int(*cmp)(const void *, const void *))
static int _upb_mapsorter_cmpstr(const void *_a, const void *_b)
static int _upb_mapsorter_cmpbool(const void *_a, const void *_b)
static int _upb_mapsorter_cmpi32(const void *_a, const void *_b)
void * _upb_Array_Resize_fallback(upb_Array **arr_ptr, size_t size, int elem_size_lg2, upb_Arena *arena)
#define UPB_MAPTYPE_STRING
UPB_INLINE bool upb_strtable_remove2(upb_strtable *t, const char *key, size_t len, upb_value *val)
const upb_MiniTable_Extension * _upb_extreg_get(const upb_ExtensionRegistry *r, const upb_MiniTable *l, uint32_t num)
void _upb_Message_Clearext(upb_Message *msg, const upb_MiniTable_Extension *ext_l)
UPB_INLINE bool _upb_Array_Resize(upb_Array *arr, size_t size, upb_Arena *arena)
UPB_INLINE upb_strview upb_tabstrview(upb_tabkey key)
UPB_INLINE upb_Array * _upb_Array_New(upb_Arena *a, size_t init_size, int elem_size_lg2)
upb_ExtensionRegistry * upb_ExtensionRegistry_New(upb_Arena *arena)
void _upb_Message_Clear(upb_Message *msg, const upb_MiniTable *l)
bool _upb_array_realloc(upb_Array *arr, size_t min_size, upb_Arena *arena)
static void extreg_key(char *buf, const upb_MiniTable *l, uint32_t fieldnum)
static const size_t overhead
static int _upb_mapsorter_cmpu32(const void *_a, const void *_b)
UPB_INLINE void _upb_map_fromkey(upb_strview key, void *out, size_t size)
UPB_INLINE bool upb_strtable_insert(upb_strtable *t, const char *key, upb_value val)
UPB_INLINE size_t upb_table_size(const upb_table *t)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:41