diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2014-08-18 20:09:52 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2014-08-18 20:09:52 +0300 |
commit | 1dd9f1900fca0c137324c05a9421f1ba180b2470 (patch) | |
tree | f0788fa698b0c49bc06dfea181a1d062a4feb09f /pb.h | |
parent | 0b517b07789049089e19b714311c596399d53f8e (diff) |
Change the _count fields to use pb_size_t datatype.
Update issue 82
Status: FixedInGit
Diffstat (limited to 'pb.h')
-rw-r--r-- | pb.h | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -187,12 +187,15 @@ typedef uint8_t pb_type_t; * and array counts. */ #if defined(PB_FIELD_32BIT) +#define PB_SIZE_MAX ((uint32_t)-1) typedef uint32_t pb_size_t; typedef int32_t pb_ssize_t; #elif defined(PB_FIELD_16BIT) +#define PB_SIZE_MAX ((uint16_t)-1) typedef uint16_t pb_size_t; typedef int16_t pb_ssize_t; #else +#define PB_SIZE_MAX ((uint8_t)-1) typedef uint8_t pb_size_t; typedef int8_t pb_ssize_t; #endif @@ -241,11 +244,11 @@ STATIC_ASSERT(sizeof(uint64_t) == 8, UINT64_T_WRONG_SIZE) * It has the number of bytes in the beginning, and after that an array. * Note that actual structs used will have a different length of bytes array. */ -#define PB_BYTES_ARRAY_T(n) struct { size_t size; uint8_t bytes[n]; } +#define PB_BYTES_ARRAY_T(n) struct { pb_size_t size; uint8_t bytes[n]; } #define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes)) struct _pb_bytes_array_t { - size_t size; + pb_size_t size; uint8_t bytes[1]; }; typedef struct _pb_bytes_array_t pb_bytes_array_t; |