nv-facutil-strict-aloc
v1.0.4
Published
nv-facutil-strict-aloc ======================= - simulate a mem allocator - simple version of nv-mem-offset-mgmt - aloc how many MUST free same size
Downloads
2
Readme
nv-facutil-strict-aloc
- simulate a mem allocator
- simple version of nv-mem-offset-mgmt
- aloc how many MUST free same size
install
- npm install nv-facutil-strict-aloc
splitted
usage
const x = require("nv-facutil-strict-aloc");
example
> var zone = x(10,Uint8Array)
> zone
Zone(2) [
0,
10,
store: Uint8Array(10) [
0, 0, 0, 0, 0,
0, 0, 0, 0, 0
],
szd: {},
si: 0
]
> zone.aloc(2)
0
> zone
Zone(2) [
2,
10,
store: Uint8Array(10) [
0, 0, 0, 0, 0,
0, 0, 0, 0, 0
],
szd: { '0': 2 },
si: 0
]
> zone.aloc(4)
2
> zone
Zone(2) [
6,
10,
store: Uint8Array(10) [
0, 0, 0, 0, 0,
0, 0, 0, 0, 0
],
szd: { '0': 2, '2': 4 },
si: 2
]
> zone.aloc(3)
6
> zone
Zone(2) [
9,
10,
store: Uint8Array(10) [
0, 0, 0, 0, 0,
0, 0, 0, 0, 0
],
szd: { '0': 2, '2': 4, '6': 3 },
si: 2
]
> zone.aloc(1)
9
> zone
Zone(0) [
store: Uint8Array(10) [
0, 0, 0, 0, 0,
0, 0, 0, 0, 0
],
szd: { '0': 2, '2': 4, '6': 3, '9': 1 },
si: 0
]
> zone.aloc(1)
-1
> zone.free(6)
true
>
> zone
Zone(2) [
6,
9,
store: Uint8Array(10) [
0, 0, 0, 0, 0,
0, 0, 0, 0, 0
],
szd: { '0': 2, '2': 4, '9': 1 },
si: 0
]
>
METHODS
.aloc : (size: @must_ge_1 ) -> index
.free : (index) -> Boolean
.free_without_check: (index) -> Void
.unset: (index,empty=0) -> Boolean
.unset_without_check: (index,empty=0) -> Void
APIS
LICENSE
- ISC