| 220 | */ |
| 221 | |
| 222 | static uint16_t |
| 223 | zap_leaf_array_create(zap_leaf_t *l, const char *buf, |
| 224 | int integer_size, int num_integers) |
| 225 | { |
| 226 | uint16_t chunk_head; |
| 227 | uint16_t *chunkp = &chunk_head; |
| 228 | int byten = 0; |
| 229 | uint64_t value = 0; |
| 230 | int shift = (integer_size - 1) * 8; |
| 231 | int len = num_integers; |
| 232 | |
| 233 | ASSERT3U(num_integers * integer_size, <=, ZAP_MAXVALUELEN); |
| 234 | |
| 235 | while (len > 0) { |
| 236 | uint16_t chunk = zap_leaf_chunk_alloc(l); |
| 237 | struct zap_leaf_array *la = &ZAP_LEAF_CHUNK(l, chunk).l_array; |
| 238 | |
| 239 | la->la_type = ZAP_CHUNK_ARRAY; |
| 240 | for (int i = 0; i < ZAP_LEAF_ARRAY_BYTES; i++) { |
| 241 | if (byten == 0) |
| 242 | value = ldv(integer_size, buf); |
| 243 | la->la_array[i] = value >> shift; |
| 244 | value <<= 8; |
| 245 | if (++byten == integer_size) { |
| 246 | byten = 0; |
| 247 | buf += integer_size; |
| 248 | if (--len == 0) |
| 249 | break; |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | *chunkp = chunk; |
| 254 | chunkp = &la->la_next; |
| 255 | } |
| 256 | *chunkp = CHAIN_END; |
| 257 | |
| 258 | return (chunk_head); |
| 259 | } |
| 260 | |
| 261 | static void |
| 262 | zap_leaf_array_free(zap_leaf_t *l, uint16_t *chunkp) |
no test coverage detected