Replace PB_MANY_FIELDS with PB_FIELD_16BIT and PB_FIELD_32BIT.
This allows more precise control over the memory use vs. field size.
This commit is contained in:
19
pb.h
19
pb.h
@@ -33,6 +33,11 @@
|
||||
#define PB_MAX_REQUIRED_FIELDS 64
|
||||
#endif
|
||||
|
||||
#if PB_MAX_REQUIRED_FIELDS < 64
|
||||
#warning You should not lower PB_MAX_REQUIRED_FIELDS from the default value (64). \
|
||||
The automatic checks against too low value will not be active.
|
||||
#endif
|
||||
|
||||
/* List of possible field types. These are used in the autogenerated code.
|
||||
* Least-significant 4 bits tell the scalar type
|
||||
* Most-significant 4 bits specify repeated/required/packed etc.
|
||||
@@ -99,21 +104,29 @@ typedef enum {
|
||||
|
||||
/* This structure is used in auto-generated constants
|
||||
* to specify struct fields.
|
||||
* You can change field sizes here if you need structures
|
||||
* You can change field sizes if you need structures
|
||||
* larger than 256 bytes or field tags larger than 256.
|
||||
* The compiler should complain if your .proto has such
|
||||
* structures ("initializer too large for type").
|
||||
* structures. Fix that by defining PB_FIELD_16BIT or
|
||||
* PB_FIELD_32BIT.
|
||||
*/
|
||||
typedef struct _pb_field_t pb_field_t;
|
||||
struct _pb_field_t {
|
||||
|
||||
#ifndef PB_MANY_FIELDS
|
||||
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
|
||||
uint8_t tag;
|
||||
pb_type_t type;
|
||||
uint8_t data_offset; /* Offset of field data, relative to previous field. */
|
||||
int8_t size_offset; /* Offset of array size or has-boolean, relative to data */
|
||||
uint8_t data_size; /* Data size in bytes for a single item */
|
||||
uint8_t array_size; /* Maximum number of entries in array */
|
||||
#elif defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
|
||||
uint16_t tag;
|
||||
pb_type_t type;
|
||||
uint8_t data_offset;
|
||||
int8_t size_offset;
|
||||
uint16_t data_size;
|
||||
uint16_t array_size;
|
||||
#else
|
||||
uint32_t tag;
|
||||
pb_type_t type;
|
||||
|
||||
Reference in New Issue
Block a user