Common GC operation: traverse or clear Python references in a node and its children. */
| 324 | |
| 325 | /* Common GC operation: traverse or clear Python references in a node and its children. */ |
| 326 | static int |
| 327 | node_gc_op(BPlusNode *node, visitproc visit, void *arg, int clear) |
| 328 | { |
| 329 | if (!node) { |
| 330 | return 0; |
| 331 | } |
| 332 | for (int i = 0; i < node->num_keys; i++) { |
| 333 | if (clear) { |
| 334 | Py_CLEAR(node->data[i]); |
| 335 | } else { |
| 336 | Py_VISIT(node_get_key(node, i)); |
| 337 | } |
| 338 | } |
| 339 | if (node->type == NODE_LEAF) { |
| 340 | for (int i = 0; i < node->num_keys; i++) { |
| 341 | if (clear) { |
| 342 | Py_CLEAR(node->data[node->capacity + i]); |
| 343 | } else { |
| 344 | Py_VISIT(node_get_value(node, i)); |
| 345 | } |
| 346 | } |
| 347 | } else { |
| 348 | for (int i = 0; i <= node->num_keys; i++) { |
| 349 | BPlusNode *child = node_get_child(node, i); |
| 350 | if (clear) { |
| 351 | node_gc_op(child, NULL, NULL, 1); |
| 352 | } else if (child && node_gc_op(child, visit, arg, 0)) { |
| 353 | return -1; |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | return 0; |
| 358 | } |
| 359 | |
| 360 | static int |
| 361 | node_traverse(BPlusNode *node, visitproc visit, void *arg) |
no test coverage detected