Differences From Artifact [d8bc2c6ad4]:
- File
src/OFDataArray+MessagePackValue.m
— part of check-in
[2a27cf3000]
at
2016-01-03 00:41:26
on branch trunk
— Update copyright
While at it, also update the mail address. (user: js, size: 11497) [annotate] [blame] [check-ins using] [more...]
To Artifact [36fe618ac5]:
- File src/OFDataArray+MessagePackValue.m — part of check-in [e0b9167693] at 2016-02-21 15:37:42 on branch trunk — Make use of C99-style for loops (user: js, size: 11504) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
53 54 55 56 57 58 59 | ((uint64_t)buffer[6] << 8) | buffer[7]; } static size_t parseArray(const uint8_t *buffer, size_t length, id *object, size_t count) { void *pool; | | < | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | ((uint64_t)buffer[6] << 8) | buffer[7]; } static size_t parseArray(const uint8_t *buffer, size_t length, id *object, size_t count) { void *pool; size_t pos = 0; /* * Don't use capacity! For data and strings, this is safe, as we can * check if we still have enough bytes left. For an array however, we * can't know this, as every child can be more than one byte. */ *object = [OFMutableArray array]; for (size_t i = 0; i < count; i++) { id child; size_t childLength; pool = objc_autoreleasePoolPush(); childLength = parseObject(buffer + pos, length - pos, &child); if (childLength == 0 || child == nil) { |
︙ | ︙ | |||
90 91 92 93 94 95 96 | return pos; } static size_t parseTable(const uint8_t *buffer, size_t length, id *object, size_t count) { void *pool; | | < | | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | return pos; } static size_t parseTable(const uint8_t *buffer, size_t length, id *object, size_t count) { void *pool; size_t pos = 0; /* * Don't use capacity! For data and strings, this is safe, as we can * check if we still have enough bytes left. For a dictionary however, * we can't know this, as every key / value can be more than one byte. */ *object = [OFMutableDictionary dictionary]; for (size_t i = 0; i < count; i++) { id key, value; size_t keyLength, valueLength; pool = objc_autoreleasePoolPush(); keyLength = parseObject(buffer + pos, length - pos, &key); if (keyLength == 0 || key == nil) { |
︙ | ︙ | |||
136 137 138 139 140 141 142 | return pos; } static size_t parseObject(const uint8_t *buffer, size_t length, id *object) { | | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | return pos; } static size_t parseObject(const uint8_t *buffer, size_t length, id *object) { size_t count; int8_t type; OFDataArray *data; if (length < 1) goto error; /* positive fixint */ |
︙ | ︙ | |||
240 241 242 243 244 245 246 | uint8_t u8[4]; float f; } f; if (length < 5) goto error; | | | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | uint8_t u8[4]; float f; } f; if (length < 5) goto error; for (size_t i = 0; i < 4; i++) f.u8[i] = buffer[i + 1]; *object = [OFNumber numberWithFloat: OF_BSWAP_FLOAT_IF_LE(f.f)]; return 5; case 0xCB:; /* float 64 */ union { uint8_t u8[8]; double d; } d; if (length < 9) goto error; for (size_t i = 0; i < 8; i++) d.u8[i] = buffer[i + 1]; *object = [OFNumber numberWithDouble: OF_BSWAP_DOUBLE_IF_LE(d.d)]; return 9; /* nil */ case 0xC0: |
︙ | ︙ |