This function is used to iterate through all the zipmap elements. * In the first call the first argument is the pointer to the zipmap + 1. * In the next calls what zipmapNext returns is used as first argument. * Example: * * unsigned char *i = zipmapRewind(my_zipmap); * while((i = zipmapNext(i,&key,&klen,&value,&vlen)) != NULL) { * printf("%d bytes key at $p\n", klen, key); * print
| 317 | * } |
| 318 | */ |
| 319 | unsigned char *zipmapNext(unsigned char *zm, unsigned char **key, unsigned int *klen, unsigned char **value, unsigned int *vlen) { |
| 320 | if (zm[0] == ZIPMAP_END) return NULL; |
| 321 | if (key) { |
| 322 | *key = zm; |
| 323 | *klen = zipmapDecodeLength(zm); |
| 324 | *key += ZIPMAP_LEN_BYTES(*klen); |
| 325 | } |
| 326 | zm += zipmapRawKeyLength(zm); |
| 327 | if (value) { |
| 328 | *value = zm+1; |
| 329 | *vlen = zipmapDecodeLength(zm); |
| 330 | *value += ZIPMAP_LEN_BYTES(*vlen); |
| 331 | } |
| 332 | zm += zipmapRawValueLength(zm); |
| 333 | return zm; |
| 334 | } |
| 335 | |
| 336 | /* Search a key and retrieve the pointer and len of the associated value. |
| 337 | * If the key is found the function returns 1, otherwise 0. */ |
no test coverage detected