-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
83 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
static inline int unpack_container_header(unpack_context* ctx, const char* data, Py_ssize_t len, Py_ssize_t* off) | ||
{ | ||
assert(len >= *off); | ||
uint32_t size; | ||
const unsigned char *const p = (unsigned char*)data + *off; | ||
|
||
#define inc_offset(inc) \ | ||
if (len - *off < inc) \ | ||
return 0; \ | ||
*off += inc; | ||
|
||
switch (*p) { | ||
case var_offset: | ||
inc_offset(3); | ||
size = _msgpack_load16(uint16_t, p + 1); | ||
break; | ||
case var_offset + 1: | ||
inc_offset(5); | ||
size = _msgpack_load32(uint32_t, p + 1); | ||
break; | ||
#ifdef USE_CASE_RANGE | ||
case fixed_offset + 0x0 ... fixed_offset + 0xf: | ||
#else | ||
case fixed_offset + 0x0: | ||
case fixed_offset + 0x1: | ||
case fixed_offset + 0x2: | ||
case fixed_offset + 0x3: | ||
case fixed_offset + 0x4: | ||
case fixed_offset + 0x5: | ||
case fixed_offset + 0x6: | ||
case fixed_offset + 0x7: | ||
case fixed_offset + 0x8: | ||
case fixed_offset + 0x9: | ||
case fixed_offset + 0xa: | ||
case fixed_offset + 0xb: | ||
case fixed_offset + 0xc: | ||
case fixed_offset + 0xd: | ||
case fixed_offset + 0xe: | ||
case fixed_offset + 0xf: | ||
#endif | ||
++*off; | ||
size = ((unsigned int)*p) & 0x0f; | ||
break; | ||
default: | ||
PyErr_SetString(PyExc_ValueError, "Unexpected type header on stream"); | ||
return -1; | ||
} | ||
unpack_callback_uint32(&ctx->user, size, &ctx->stack[0].obj); | ||
return 1; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters