MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / n_free

Function n_free

dep/hfsutils/libhfs/node.c:104–146  ·  view source on GitHub ↗

* NAME: node->free() * DESCRIPTION: deallocate and remove a b*-tree node */

Source from the content-addressed store, hash-verified

102 * DESCRIPTION: deallocate and remove a b*-tree node
103 */
104int n_free(node *np)
105{
106 btree *bt = np->bt;
107 node sib;
108
109 if (bt->hdr.bthFNode == np->nnum)
110 bt->hdr.bthFNode = np->nd.ndFLink;
111
112 if (bt->hdr.bthLNode == np->nnum)
113 bt->hdr.bthLNode = np->nd.ndBLink;
114
115 if (np->nd.ndFLink > 0)
116 {
117 if (bt_getnode(&sib, bt, np->nd.ndFLink) == -1)
118 goto fail;
119
120 sib.nd.ndBLink = np->nd.ndBLink;
121
122 if (bt_putnode(&sib) == -1)
123 goto fail;
124 }
125
126 if (np->nd.ndBLink > 0)
127 {
128 if (bt_getnode(&sib, bt, np->nd.ndBLink) == -1)
129 goto fail;
130
131 sib.nd.ndFLink = np->nd.ndFLink;
132
133 if (bt_putnode(&sib) == -1)
134 goto fail;
135 }
136
137 BMCLR(bt->map, np->nnum);
138 ++bt->hdr.bthFree;
139
140 bt->flags |= HFS_BT_UPDATE_HDR;
141
142 return 0;
143
144fail:
145 return -1;
146}
147
148/*
149 * NAME: compact()

Callers 3

joinFunction · 0.85
n_deleteFunction · 0.85
bt_deleteFunction · 0.85

Calls 2

bt_getnodeFunction · 0.85
bt_putnodeFunction · 0.85

Tested by

no test coverage detected