MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / node_destroy

Function node_destroy

python/bplustree_c_src/node_ops.c:121–145  ·  view source on GitHub ↗

Destroy a node and decref all Python objects */

Source from the content-addressed store, hash-verified

119
120/* Destroy a node and decref all Python objects */
121void node_destroy(BPlusNode *node) {
122 if (!node) return;
123
124 /* Decref all keys */
125 for (int i = 0; i < node->num_keys; i++) {
126 Py_XDECREF(node_get_key(node, i));
127 }
128
129 if (node->type == NODE_LEAF) {
130 /* Decref all values */
131 for (int i = 0; i < node->num_keys; i++) {
132 Py_XDECREF(node_get_value(node, i));
133 }
134 } else {
135 /* Recursively destroy children */
136 for (int i = 0; i <= node->num_keys; i++) {
137 BPlusNode *child = node_get_child(node, i);
138 if (child) {
139 node_destroy(child);
140 }
141 }
142 }
143
144 cache_aligned_free(node);
145}
146
147/* Clear a single slot: decref or destroy payload and null out key/value or child pointer */
148static void node_clear_slot(BPlusNode *node, int i) {

Callers 5

node_insert_branchFunction · 0.85
BPlusTree_deallocFunction · 0.85
py_check_data_alignmentFunction · 0.85
node_clear_slotFunction · 0.85
node_insert_leafFunction · 0.85

Calls 4

node_get_keyFunction · 0.85
node_get_valueFunction · 0.85
node_get_childFunction · 0.85
cache_aligned_freeFunction · 0.85

Tested by

no test coverage detected