diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-08-12 13:47:24 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-08-12 13:47:24 -0700 |
commit | 2282d2489bd8db3cd4ddbe0dd813732bffcf6452 (patch) | |
tree | 814fc94cd8ca4993363fb0ebe45b14e320a7a792 /src/upb.h | |
parent | 89a6c6d71f87bab63ee17c60f0feb56215f5c116 (diff) |
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.
Diffstat (limited to 'src/upb.h')
-rw-r--r-- | src/upb.h | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -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; }; |