Return the number of elements in a hash. */
| 312 | |
| 313 | /* Return the number of elements in a hash. */ |
| 314 | unsigned long hashTypeLength(robj_roptr o) { |
| 315 | unsigned long length = ULONG_MAX; |
| 316 | |
| 317 | if (o->encoding == OBJ_ENCODING_ZIPLIST) { |
| 318 | length = ziplistLen((unsigned char*)ptrFromObj(o)) / 2; |
| 319 | } else if (o->encoding == OBJ_ENCODING_HT) { |
| 320 | length = dictSize((const dict*)ptrFromObj(o)); |
| 321 | } else { |
| 322 | serverPanic("Unknown hash encoding"); |
| 323 | } |
| 324 | return length; |
| 325 | } |
| 326 | |
| 327 | hashTypeIterator *hashTypeInitIterator(robj_roptr subject) { |
| 328 | hashTypeIterator *hi = (hashTypeIterator*)zmalloc(sizeof(hashTypeIterator), MALLOC_LOCAL); |
no test coverage detected