1# @ajax/mesh-view-alloc
23The view heap's first-fit page allocator (meshd gives each loaded program its view from it).
45First-fit allocation over the view heap's VIEW_PAGES pages (programs.rs Heap). A view of 0 bytes takes no page (offset 0). Offsets are mailbox offsets. Freeing a free page is a bug in meshd: it aborts, as the Rust panics.
67```c
8#include "mesh/view_alloc.h"
9```
1011## Ported from
1213[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT): crates/mesh-host/src/programs.rs: `Heap` (alloc, free, free_pages, largest_run), `pages`.
1415## Tests
1617- `tests/view_alloc.c`: programs.rs's `heap_first_fit` and `heap_double_free` (the abort is checked in a child process).
1819## Licence
2021MIT. See the repository's LICENSE.