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

Function activeDefragList

app/redis-6.2.6/src/defrag.c:292–323  ·  view source on GitHub ↗

Defrag a list of ptr, sds or robj string values */

Source from the content-addressed store, hash-verified

290
291/* Defrag a list of ptr, sds or robj string values */
292long activeDefragList(list *l, int val_type) {
293 long defragged = 0;
294 listNode *ln, *newln;
295 for (ln = l->head; ln; ln = ln->next) {
296 if ((newln = activeDefragAlloc(ln))) {
297 if (newln->prev)
298 newln->prev->next = newln;
299 else
300 l->head = newln;
301 if (newln->next)
302 newln->next->prev = newln;
303 else
304 l->tail = newln;
305 ln = newln;
306 defragged++;
307 }
308 if (val_type == DEFRAG_SDS_DICT_VAL_IS_SDS) {
309 sds newsds, sdsele = ln->value;
310 if ((newsds = activeDefragSds(sdsele)))
311 ln->value = newsds, defragged++;
312 } else if (val_type == DEFRAG_SDS_DICT_VAL_IS_STROB) {
313 robj *newele, *ele = ln->value;
314 if ((newele = activeDefragStringOb(ele, &defragged)))
315 ln->value = newele;
316 } else if (val_type == DEFRAG_SDS_DICT_VAL_VOID_PTR) {
317 void *newptr, *ptr = ln->value;
318 if ((newptr = activeDefragAlloc(ptr)))
319 ln->value = newptr, defragged++;
320 }
321 }
322 return defragged;
323}
324
325/* Defrag a list of sds values and a dict with the same sds keys */
326long activeDefragSdsListAndDict(list *l, dict *d, int dict_val_type) {

Callers

nothing calls this directly

Calls 3

activeDefragAllocFunction · 0.85
activeDefragSdsFunction · 0.85
activeDefragStringObFunction · 0.85

Tested by

no test coverage detected