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

Function activeDefragSdsDict

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

Defrag a dict with sds key and optional value (either ptr, sds or robj string) */

Source from the content-addressed store, hash-verified

260
261/* Defrag a dict with sds key and optional value (either ptr, sds or robj string) */
262long activeDefragSdsDict(dict* d, int val_type) {
263 dictIterator *di;
264 dictEntry *de;
265 long defragged = 0;
266 di = dictGetIterator(d);
267 while((de = dictNext(di)) != NULL) {
268 sds sdsele = dictGetKey(de), newsds;
269 if ((newsds = activeDefragSds(sdsele)))
270 de->key = newsds, defragged++;
271 /* defrag the value */
272 if (val_type == DEFRAG_SDS_DICT_VAL_IS_SDS) {
273 sdsele = dictGetVal(de);
274 if ((newsds = activeDefragSds(sdsele)))
275 de->v.val = newsds, defragged++;
276 } else if (val_type == DEFRAG_SDS_DICT_VAL_IS_STROB) {
277 robj *newele, *ele = dictGetVal(de);
278 if ((newele = activeDefragStringOb(ele, &defragged)))
279 de->v.val = newele;
280 } else if (val_type == DEFRAG_SDS_DICT_VAL_VOID_PTR) {
281 void *newptr, *ptr = dictGetVal(de);
282 if ((newptr = activeDefragAlloc(ptr)))
283 de->v.val = newptr, defragged++;
284 }
285 defragged += dictIterDefragEntry(di);
286 }
287 dictReleaseIterator(di);
288 return defragged;
289}
290
291/* Defrag a list of ptr, sds or robj string values */
292long activeDefragList(list *l, int val_type) {

Callers 3

defragHashFunction · 0.85
defragSetFunction · 0.85
defragOtherGlobalsFunction · 0.85

Calls 7

activeDefragSdsFunction · 0.85
activeDefragStringObFunction · 0.85
activeDefragAllocFunction · 0.85
dictIterDefragEntryFunction · 0.85
dictGetIteratorFunction · 0.70
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected