Protocol Buffers - Google's data interchange format (grpc依赖) https://developers.google.com/protocol-buffers/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
1.4 KiB

#ifndef UPB_DECODE_INT_H_
#define UPB_DECODE_INT_H_
#include "upb/upb.int.h"
/* Must be last. */
#include "upb/port_def.inc"
typedef struct upb_decstate {
const char *limit; /* End of delimited region or end of buffer. */
const char *fastend; /* The end of the entire buffer - 16 */
const char *fastlimit; /* UPB_MIN(limit, fastend) */
upb_arena arena;
int depth;
uint32_t end_group; /* Set to field number of END_GROUP tag, if any. */
jmp_buf err;
} upb_decstate;
const char *fastdecode_dispatch(upb_decstate *d, const char *ptr, upb_msg *msg,
const upb_msglayout *table, uint64_t hasbits);
const char *fastdecode_err(upb_decstate *d);
UPB_INLINE
upb_msg *decode_newmsg_ceil(upb_decstate *d, const upb_msglayout *l,
int msg_ceil_bytes) {
size_t size = l->size + sizeof(upb_msg_internal);
char *msg_data;
if (UPB_LIKELY(msg_ceil_bytes > 0 && _upb_arenahas(&d->arena, msg_ceil_bytes))) {
UPB_ASSERT(size <= (size_t)msg_ceil_bytes);
msg_data = d->arena.head.ptr;
d->arena.head.ptr += size;
UPB_UNPOISON_MEMORY_REGION(msg_data, msg_ceil_bytes);
memset(msg_data, 0, msg_ceil_bytes);
UPB_POISON_MEMORY_REGION(msg_data + size, msg_ceil_bytes - size);
} else {
msg_data = (char*)upb_arena_malloc(&d->arena, size);
memset(msg_data, 0, size);
}
return msg_data + sizeof(upb_msg_internal);
}
#include "upb/port_undef.inc"
#endif /* UPB_DECODE_INT_H_ */