Add new entry to head node of quicklist. * * Returns 0 if used existing head. * Returns 1 if new head created. */
| 490 | * Returns 0 if used existing head. |
| 491 | * Returns 1 if new head created. */ |
| 492 | int quicklistPushHead(quicklist *quicklist, void *value, size_t sz) { |
| 493 | quicklistNode *orig_head = quicklist->head; |
| 494 | assert(sz < UINT32_MAX); /* TODO: add support for quicklist nodes that are sds encoded (not zipped) */ |
| 495 | if (likely( |
| 496 | _quicklistNodeAllowInsert(quicklist->head, quicklist->fill, sz))) { |
| 497 | quicklist->head->zl = |
| 498 | ziplistPush(quicklist->head->zl, value, sz, ZIPLIST_HEAD); |
| 499 | quicklistNodeUpdateSz(quicklist->head); |
| 500 | } else { |
| 501 | quicklistNode *node = quicklistCreateNode(); |
| 502 | node->zl = ziplistPush(ziplistNew(), value, sz, ZIPLIST_HEAD); |
| 503 | |
| 504 | quicklistNodeUpdateSz(node); |
| 505 | _quicklistInsertNodeBefore(quicklist, quicklist->head, node); |
| 506 | } |
| 507 | quicklist->count++; |
| 508 | quicklist->head->count++; |
| 509 | return (orig_head != quicklist->head); |
| 510 | } |
| 511 | |
| 512 | /* Add new entry to tail node of quicklist. |
| 513 | * |
no test coverage detected