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

Function node_clear_slot

python/bplustree_c_src/node_ops.c:148–169  ·  view source on GitHub ↗

Clear a single slot: decref or destroy payload and null out key/value or child pointer */

Source from the content-addressed store, hash-verified

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) {
149 if (i < 0 || i >= node->capacity) {
150 return; /* Invalid index */
151 }
152
153 if (node->type == NODE_LEAF) {
154 Py_XDECREF(node_get_key(node, i));
155 Py_XDECREF(node_get_value(node, i));
156 node_set_key(node, i, NULL);
157 node_set_value(node, i, NULL);
158 } else {
159 /* For branch nodes, we only clear during deletion operations
160 * where it's safe to destroy the child subtree */
161 BPlusNode *child = node_get_child(node, i);
162 if (child) {
163 node_destroy(child);
164 }
165 Py_XDECREF(node_get_key(node, i));
166 node_set_key(node, i, NULL);
167 node_set_child(node, i, NULL);
168 }
169}
170
171/* Insert into leaf node */
172int node_insert_leaf(BPlusNode *node, PyObject *key, PyObject *value,

Callers 1

node_deleteFunction · 0.85

Calls 7

node_get_keyFunction · 0.85
node_get_valueFunction · 0.85
node_set_keyFunction · 0.85
node_set_valueFunction · 0.85
node_get_childFunction · 0.85
node_destroyFunction · 0.85
node_set_childFunction · 0.85

Tested by

no test coverage detected