protobuf-c-text
Library to generate & parse text format protobufs in C.
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups
protobuf-c-util.h
Go to the documentation of this file.
1 #ifndef PROTOBUF_C_UTIL_H
2 #define PROTOBUF_C_UTIL_H
3 
18 /* These are lifted from the protobuf-c lib */
19 
21 #define STRUCT_MEMBER_P(struct_p, struct_offset) \
22  ((void *) ((uint8_t *) (struct_p) + (struct_offset)))
23 
25 #define STRUCT_MEMBER(member_type, struct_p, struct_offset) \
26  (*(member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset)))
27 
29 #define STRUCT_MEMBER_PTR(member_type, struct_p, struct_offset) \
30  ((member_type *) STRUCT_MEMBER_P((struct_p), (struct_offset)))
31 
33 #define PBC_FREE(ptr) (allocator? allocator->free(allocator->allocator_data, \
34  ptr): free(ptr))
35 
37 #define PBC_ALLOC(size) (allocator? \
38  allocator->alloc(allocator->allocator_data, size): \
39  malloc(size))
40 
42 #define ST_FREE(ptr) (state->allocator? \
43  state->allocator->free(state->allocator-> \
44  allocator_data, ptr): \
45  free(ptr))
46 
48 #define ST_ALLOC(size) (state->allocator? \
49  state->allocator->alloc(state->allocator-> \
50  allocator_data, size): \
51  malloc(size))
52 
53 #endif /* PROTOBUF_C_UTIL_H */