2.4.1 • Published 5 years ago

buddy-tree v2.4.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

buddy-tree

Immutable buddy memory allocation

Installation

npm install --save buddy-tree

Usage

import * as buddyTree from 'buddy-tree'

let tree = buddyTree.createTree(16);
[tree, address1] = buddyTree.allocate(tree, 1);
[tree, address2] = buddyTree.allocate(tree, 1);
[tree, address3] = buddyTree.allocate(tree, 4);
tree = buddyTree.deallocate(tree, address2);

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.createTree(16);
const [result, address] = buddyTree.allocate(tree, 7);

buddyTree.deallocate(tree, address)

Frees all the memory consumed at the address. Returns the modified tree.

2.4.1

5 years ago

2.4.0

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago