Skip to content

Commit a2f3689

Browse files
author
David LeBlanc
committed
Older compilers don't allow declaring variables other than at the top of
the block if it is a C file.
1 parent 2d54c0e commit a2f3689

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/unpack.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ static inline int template_callback_false(unpack_user* u, msgpack_object* o)
189189

190190
static inline int template_callback_array(unpack_user* u, unsigned int n, msgpack_object* o)
191191
{
192+
size_t size;
192193
// Let's leverage the fact that sizeof(msgpack_object) is a compile time constant
193194
// to check for int overflows.
194195
// Note - while n is constrained to 32-bit, the product of n * sizeof(msgpack_object)
@@ -199,7 +200,7 @@ static inline int template_callback_array(unpack_user* u, unsigned int n, msgpac
199200
o->type = MSGPACK_OBJECT_ARRAY;
200201
o->via.array.size = 0;
201202

202-
size_t size = n * sizeof(msgpack_object);
203+
size = n * sizeof(msgpack_object);
203204

204205
if (*u->z == NULL) {
205206
*u->z = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
@@ -228,6 +229,7 @@ static inline int template_callback_array_item(unpack_user* u, msgpack_object* c
228229

229230
static inline int template_callback_map(unpack_user* u, unsigned int n, msgpack_object* o)
230231
{
232+
size_t size;
231233
// Let's leverage the fact that sizeof(msgpack_object_kv) is a compile time constant
232234
// to check for int overflows
233235
// Note - while n is constrained to 32-bit, the product of n * sizeof(msgpack_object)
@@ -239,7 +241,7 @@ static inline int template_callback_map(unpack_user* u, unsigned int n, msgpack_
239241
o->type = MSGPACK_OBJECT_MAP;
240242
o->via.map.size = 0;
241243

242-
size_t size = n * sizeof(msgpack_object_kv);
244+
size = n * sizeof(msgpack_object_kv);
243245

244246
if (*u->z == NULL) {
245247
*u->z = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);

0 commit comments

Comments
 (0)