Create a new skiplist. */
| 78 | |
| 79 | /* Create a new skiplist. */ |
| 80 | zskiplist *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 |
no test coverage detected