From 2282d2489bd8db3cd4ddbe0dd813732bffcf6452 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 12 Aug 2009 13:47:24 -0700 Subject: Refactoring: unify upb_msg. The cost is that a upb_msg will now always have an overhead of 2*sizeof(void*). This is comparable to proto2 overhead. The benefit is that upb_msg is now self-describing, and read-only algorithms can now operate on a upb_msg regardless of the memory-management scheme. Also, upb_array and upb_string now know inherently if they own their associated memory, and upb_array has a generic pointer for memory management purposes like upb_msg does. --- src/upb.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/upb.h') diff --git a/src/upb.h b/src/upb.h index 83917af..27bf5fc 100644 --- a/src/upb.h +++ b/src/upb.h @@ -35,8 +35,6 @@ extern "C" { #define UPB_INDEX(base, i, m) (void*)((char*)(base) + ((i)*(m))) -INLINE uint32_t max(uint32_t a, uint32_t b) { return a > b ? a : b; } - /* Fundamental types and type constants. **************************************/ /* A list of types as they are encoded on-the-wire. */ @@ -104,7 +102,7 @@ union upb_value { bool _bool; struct upb_string *str; struct upb_array *arr; - void *msg; + struct upb_msg *msg; }; /* A pointer to a .proto value. The owner must have an out-of-band way of @@ -119,7 +117,7 @@ union upb_value_ptr { bool *_bool; struct upb_string **str; struct upb_array **arr; - void **msg; + struct upb_msg **msg; void *_void; }; -- cgit v1.2.3