buddy-tree
Immutable buddy memory allocation
Installation
npm install --save buddy-tree
Usage
let tree = buddyTree;tree address1 = buddyTree;tree address2 = buddyTree;tree address3 = buddyTree;tree = buddyTree;
Methods
buddyTree.allocate(tree, size=1)
Find a contiguous free span of memory of size
and consumes it. Returns the modified tree and the address of the memory.
Consumes 2ⁿ >= size
of the memory. This means in the worst case half the memory is wasted.
const tree = buddyTree;const result address = buddyTree;
buddyTree.deallocate(tree, address)
Frees all the memory consumed at the address. Returns the modified tree.