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

Function node_create

python/bplustree_c_src/node_ops.c:92–118  ·  view source on GitHub ↗

Create a new node */

Source from the content-addressed store, hash-verified

90
91/* Create a new node */
92BPlusNode* node_create(NodeType type, uint16_t capacity) {
93 size_t data_size;
94
95 if (type == NODE_LEAF) {
96 data_size = capacity * 2 * sizeof(PyObject*);
97 } else {
98 data_size = (capacity * 2 + 1) * sizeof(PyObject*);
99 }
100
101 BPlusNode *node = (BPlusNode*)cache_aligned_alloc(sizeof(BPlusNode) + data_size);
102 if (!node) {
103 PyErr_NoMemory();
104 return NULL;
105 }
106
107 /* Initialize metadata */
108 node->num_keys = 0;
109 node->capacity = capacity;
110 node->type = type;
111 node->_unused = 0; /* Reserved for future use */
112 node->next = NULL;
113
114 /* Clear data array */
115 memset(node->data, 0, data_size);
116
117 return node;
118}
119
120/* Destroy a node and decref all Python objects */
121void node_destroy(BPlusNode *node) {

Callers 5

tree_insertFunction · 0.85
node_insert_branchFunction · 0.85
BPlusTree_initFunction · 0.85
py_check_data_alignmentFunction · 0.85
node_insert_leafFunction · 0.85

Calls 1

cache_aligned_allocFunction · 0.85

Tested by

no test coverage detected