MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zzlInsertAt

Function zzlInsertAt

app/redis-6.2.6/src/t_zset.c:1034–1055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1032}
1033
1034unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, sds ele, double score) {
1035 unsigned char *sptr;
1036 char scorebuf[128];
1037 int scorelen;
1038 size_t offset;
1039
1040 scorelen = d2string(scorebuf,sizeof(scorebuf),score);
1041 if (eptr == NULL) {
1042 zl = ziplistPush(zl,(unsigned char*)ele,sdslen(ele),ZIPLIST_TAIL);
1043 zl = ziplistPush(zl,(unsigned char*)scorebuf,scorelen,ZIPLIST_TAIL);
1044 } else {
1045 /* Keep offset relative to zl, as it might be re-allocated. */
1046 offset = eptr-zl;
1047 zl = ziplistInsert(zl,eptr,(unsigned char*)ele,sdslen(ele));
1048 eptr = zl+offset;
1049
1050 /* Insert score after the element. */
1051 serverAssert((sptr = ziplistNext(zl,eptr)) != NULL);
1052 zl = ziplistInsert(zl,sptr,(unsigned char*)scorebuf,scorelen);
1053 }
1054 return zl;
1055}
1056
1057/* Insert (element,score) pair in ziplist. This function assumes the element is
1058 * not yet present in the list. */

Callers 2

zzlInsertFunction · 0.85
zsetConvertFunction · 0.85

Calls 5

d2stringFunction · 0.85
ziplistPushFunction · 0.85
sdslenFunction · 0.85
ziplistInsertFunction · 0.85
ziplistNextFunction · 0.85

Tested by

no test coverage detected