An append-only memory allocator with the same interface as malloc, useful for implementing append only logs. Has no free() but does not enforce write-once.
What?
It lets you allocate a large, contiguous slab of memory up front and then alloc() within that buffer.
It is mostly useful in conjunction with things like mmap.js.
It's developed using design by contract, so you might find the library's own code style a bit unusual, but it doesn't affect usage or performance.
import Allocator from "malloc-append";const heap = new Buffer(1024 * 1024);const allocator = new Allocator(heap); // heap could also be an ArrayBufferconsole.log(allocator.inspect());let firstAddress = 0;let lastAddress = 0;for (let i = 0; i < 100; i++) { const address = allocator.alloc(64); if (firstAddress
License
Published by codemix under a permissive MIT License, see LICENSE.md.