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

Function raxRecursiveFree

app/redis-6.2.6/src/rax.c:1223–1238  ·  view source on GitHub ↗

This is the core of raxFree(): performs a depth-first scan of the * tree and releases all the nodes found. */

Source from the content-addressed store, hash-verified

1221/* This is the core of raxFree(): performs a depth-first scan of the
1222 * tree and releases all the nodes found. */
1223void raxRecursiveFree(rax *rax, raxNode *n, void (*free_callback)(void*)) {
1224 debugnode("free traversing",n);
1225 int numchildren = n->iscompr ? 1 : n->size;
1226 raxNode **cp = raxNodeLastChildPtr(n);
1227 while(numchildren--) {
1228 raxNode *child;
1229 memcpy(&child,cp,sizeof(child));
1230 raxRecursiveFree(rax,child,free_callback);
1231 cp--;
1232 }
1233 debugnode("free depth-first",n);
1234 if (free_callback && n->iskey && !n->isnull)
1235 free_callback(raxGetData(n));
1236 rax_free(n);
1237 rax->numnodes--;
1238}
1239
1240/* Free a whole radix tree, calling the specified callback in order to
1241 * free the auxiliary data. */

Callers 1

raxFreeWithCallbackFunction · 0.85

Calls 3

free_callbackFunction · 0.85
raxGetDataFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected