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

Function zslCreate

src/t_zset.cpp:80–95  ·  view source on GitHub ↗

Create a new skiplist. */

Source from the content-addressed store, hash-verified

78
79/* Create a new skiplist. */
80zskiplist *zslCreate(void) {
81 int j;
82 zskiplist *zsl;
83
84 zsl = (zskiplist*)zmalloc(sizeof(*zsl), MALLOC_SHARED);
85 zsl->level = 1;
86 zsl->length = 0;
87 zsl->header = zslCreateNode(ZSKIPLIST_MAXLEVEL,0,NULL);
88 for (j = 0; j < ZSKIPLIST_MAXLEVEL; j++) {
89 zsl->header->level(j)->forward = NULL;
90 zsl->header->level(j)->span = 0;
91 }
92 zsl->header->backward = NULL;
93 zsl->tail = NULL;
94 return zsl;
95}
96
97/* Free the specified skiplist node. The referenced SDS string representation
98 * of the element is freed too, unless node->ele is set to NULL before calling

Callers 2

createZsetObjectFunction · 0.85
zsetConvertFunction · 0.85

Calls 3

zmallocFunction · 0.85
zslCreateNodeFunction · 0.85
levelMethod · 0.80

Tested by

no test coverage detected