Implements BlockArray.
BlockArray impl | Implements BlockArray. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file BlockArray. |
C-kern/ | Implementation file BlockArray impl. |
Types | |
struct datablock_t | Export datablock_t into global namespace. |
struct ptrblock_t | Export ptrblock_t into global namespace. |
Function | |
helper | |
datablock_t | A memory block which contains the array elements. |
lifetime | |
ptrblock_t | A memory block which contains pointers to other ptrblock_t or datablock_t. |
lifetime | |
blockarray_t | |
static variables | |
lifetime | |
query | |
update | |
adaptdepth_blockarray | Adds a new root ptrblock_t and sets <ptrblock_t.childs[0]> to old root. |
test | |
build_test_node | Allocates a tree with pow(2, depth+1)-1 nodes. |
build_test_tree | Calls build_test_node to build the test tree. |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2013 Jörg Seebohn
Header file BlockArray.
Implementation file BlockArray impl.
typedef struct datablock_t datablock_t
Export datablock_t into global namespace.
typedef struct ptrblock_t ptrblock_t
Export ptrblock_t into global namespace.
struct ptrblock_t
A memory block which contains pointers to other ptrblock_t or datablock_t. The current implementation supports only one memory block size which is the same for datablock_t and ptrblock_t.
static variables | |
lifetime | |
query | |
update | |
adaptdepth_blockarray | Adds a new root ptrblock_t and sets <ptrblock_t.childs[0]> to old root. |
test | |
build_test_node | Allocates a tree with pow(2, depth+1)-1 nodes. |
build_test_tree | Calls build_test_node to build the test tree. |
static int adaptdepth_blockarray( blockarray_t * barray, uint8_t depth )
Adds a new root ptrblock_t and sets <ptrblock_t.childs[0]> to old root. This step is repeated until barray->depth >= depth. There is always added at least one new root even if depth is <= barray->depth.
static int build_test_node( void ** block, pagesize_e pgsize, uint8_t depth )
Allocates a tree with pow(2, depth+1)-1 nodes. All nodes at a depth > 0 are allocated as ptrblock_t and all nodes at depth == 0 are allocated as datablock_t. A ptrblock_t contains two childs at index 0 and maxindex.
static int build_test_tree( blockarray_t * barray, pagesize_e pgsize, uint8_t depth )
Calls build_test_node to build the test tree. The old root is expected at depth 0 and it is deallocated and replaced by the new root returned from build_test_node. The depth is changed.
Export datablock_t into global namespace.
typedef struct datablock_t datablock_t
A memory block which contains the array elements.
struct datablock_t
Export ptrblock_t into global namespace.
typedef struct ptrblock_t ptrblock_t
A memory block which contains pointers to other ptrblock_t or datablock_t.
struct ptrblock_t
Adds a new root ptrblock_t and sets ptrblock_t.childs[0] to old root.
static int adaptdepth_blockarray( blockarray_t * barray, uint8_t depth )
Allocates a tree with pow(2, depth+1)-1 nodes.
static int build_test_node( void ** block, pagesize_e pgsize, uint8_t depth )
Calls build_test_node to build the test tree.
static int build_test_tree( blockarray_t * barray, pagesize_e pgsize, uint8_t depth )