MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / zipmapLen

Function zipmapLen

src/zipmap.c:354–366  ·  view source on GitHub ↗

Return the number of entries inside a zipmap */

Source from the content-addressed store, hash-verified

352
353/* Return the number of entries inside a zipmap */
354unsigned int zipmapLen(unsigned char *zm) {
355 unsigned int len = 0;
356 if (zm[0] < ZIPMAP_BIGLEN) {
357 len = zm[0];
358 } else {
359 unsigned char *p = zipmapRewind(zm);
360 while((p = zipmapNext(p,NULL,NULL,NULL,NULL)) != NULL) len++;
361
362 /* Re-store length if small enough */
363 if (len < ZIPMAP_BIGLEN) zm[0] = len;
364 }
365 return len;
366}
367
368/* Return the raw size in bytes of a zipmap, so that we can serialize
369 * the zipmap on disk (or everywhere is needed) just writing the returned

Callers

nothing calls this directly

Calls 2

zipmapRewindFunction · 0.85
zipmapNextFunction · 0.85

Tested by

no test coverage detected