diff options
author | Joe <joe@ubuntu.localdomain> | 2010-02-22 12:19:15 -0800 |
---|---|---|
committer | Joe <joe@ubuntu.localdomain> | 2010-02-22 12:19:15 -0800 |
commit | 6fce297e9ff9f495b10281f2c5c78e6e0c2d48ad (patch) | |
tree | 42f34b519a411ce8f594a375d5be5c885ee37ed6 /include/dmerkle.hrl |
merge attempt #1
Diffstat (limited to 'include/dmerkle.hrl')
-rw-r--r-- | include/dmerkle.hrl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/dmerkle.hrl b/include/dmerkle.hrl new file mode 100644 index 00000000..b4fe2a08 --- /dev/null +++ b/include/dmerkle.hrl @@ -0,0 +1,14 @@ +-define(DMERKLE_VERSION, 2). +-define(STATIC_HEADER, 93). + +-define(d_from_blocksize(BlockSize), trunc((BlockSize - 17)/16)). +-define(pointers_from_blocksize(BlockSize), (lib_misc:ceiling(math:log(BlockSize)/math:log(2)) - 3)). +-define(pointer_for_size(Size, BlockSize), (if Size =< 16 -> 1; Size =< BlockSize -> ?pointers_from_blocksize(Size); true -> last end)). +-define(size_for_pointer(N), (2 bsl (N+2))). +-define(headersize_from_blocksize(BlockSize), (?STATIC_HEADER + ?pointers_from_blocksize(BlockSize) * 8)). +-define(aligned(Ptr, HeaderSize, BlockSize), (((Ptr - (HeaderSize)) rem BlockSize) == 0)). +-define(block(Ptr, HeaderSize, BlockSize), ((Ptr - (HeaderSize)) div BlockSize)). + +-record(node, {m=0, keys=[], children=[], offset=eof}). +-record(leaf, {m=0, values=[], offset=eof}). +-record(free, {offset,size=0,pointer=0}). |