aboutsummaryrefslogtreecommitdiffstats
path: root/pb.h
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-08-18 20:09:52 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-08-18 20:09:52 +0300
commit1dd9f1900fca0c137324c05a9421f1ba180b2470 (patch)
treef0788fa698b0c49bc06dfea181a1d062a4feb09f /pb.h
parent0b517b07789049089e19b714311c596399d53f8e (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.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/pb.h b/pb.h
index 50a07c5..c9ef48b 100644
--- a/pb.h
+++ b/pb.h
@@ -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;