Skip to content

Commit d376ce8

Browse files
author
fuli
committed
update comment in btree.h
1 parent 34aaa4e commit d376ce8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

include/btree.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ namespace alg {
5050
struct node_t {
5151
uint16_t n; // num key
5252
uint16_t flag; // flags
53-
uint32_t offset; // block offset (8 byte head)
53+
uint32_t offset; // lseek offset related to file beginning
5454
char padding[12]; // padding to 4096
5555
int32_t key[509]; // key
56-
int32_t c[510]; // childs pointers (file offsets related to 0)
56+
int32_t c[510]; // childs pointers (represented as file offsets)
5757
} __attribute__ ((packed));
5858
typedef struct node_t *node;
5959

@@ -473,7 +473,7 @@ namespace alg {
473473
}
474474

475475
/**
476-
* delete ith node
476+
* delete ith key & child.
477477
*/
478478
void delete_i(node x, int32_t i) {
479479
int j;
@@ -488,7 +488,10 @@ namespace alg {
488488
}
489489

490490
/**
491-
* allocate empty node struct
491+
* Allocate empty node struct.
492+
* A better allocator should be consider in practice,
493+
* such as re-cycling the freed up blocks on disk, so used blocks.
494+
* should be traced in some data strucuture, file header maybe.
492495
*/
493496
void * ALLOCBLK() {
494497
node x = new node_t;
@@ -500,6 +503,7 @@ namespace alg {
500503
memset(x->padding, 0xcc, sizeof(x->padding));
501504
return x;
502505
}
506+
503507
/**
504508
* Load the root block
505509
*/

0 commit comments

Comments
 (0)