diff options
| author | fiatjaf_ <fiatjaf@gmail.com> | 2026-04-05 12:08:24 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-05 12:08:24 -0300 |
| commit | 93dcd8033f50bbc127bfd927b8de3804630a260c (patch) | |
| tree | 6395d87d50fae33e441fc1b9afc91e478b7a6ea4 | |
| parent | 85dd28b2414db6c0b6a72d4ecf5d0aa35f41cc24 (diff) | |
byte order clarification
Co-authored-by: Awiteb <a@4rs.nl>
| -rw-r--r-- | 5C.md | 4 |
1 files changed, 4 insertions, 0 deletions
| @@ -34,6 +34,10 @@ Unless noted otherwise (i.e. for hex pubkeys and ids), the module passes strings | |||
| 34 | 34 | ||
| 35 | For example, if `nostr.get_content(handle)` returns `7165` that will be a pointer to a buffer at location `7165`. If that buffer starts with `[ 00 00 00 03 ]` that means it contains 3 bytes (aside from the initial four), so we can keep reading it `[ 00 00 00 03 66 6f 6f ]` and conclude that the string is `"foo"`. | 35 | For example, if `nostr.get_content(handle)` returns `7165` that will be a pointer to a buffer at location `7165`. If that buffer starts with `[ 00 00 00 03 ]` that means it contains 3 bytes (aside from the initial four), so we can keep reading it `[ 00 00 00 03 66 6f 6f ]` and conclude that the string is `"foo"`. |
| 36 | 36 | ||
| 37 | ## Numbers Convention | ||
| 38 | |||
| 39 | All numbers written by the host must use **Little-endian** byte order, matching WASM's default endianness. This applies consistently: write string length prefixes as Little-endian numbers, write number parameters as Little-endian | ||
| 40 | |||
| 37 | ## Memory Management Convention | 41 | ## Memory Management Convention |
| 38 | 42 | ||
| 39 | In order to keep the size of WASM programs small (<10kb) we recommend not including any type of garbage collector or complex allocator. Just use the simplest possible bump allocator and do not free any memory -- programs will not use a lot of memory anyway, at most they will receive a bunch of `i32` event handles from the host, which are cheap. | 43 | In order to keep the size of WASM programs small (<10kb) we recommend not including any type of garbage collector or complex allocator. Just use the simplest possible bump allocator and do not free any memory -- programs will not use a lot of memory anyway, at most they will receive a bunch of `i32` event handles from the host, which are cheap. |