Skip to content

Document null pointer behavior of the loader helpers #1280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ Besides demangling classes exported from your entry file to a handy object struc
```

* **__getString**(ptr: `number`): `string`<br />
Copies a string's value from the module's memory.
Copies a string's value from the module's memory. `ptr` must not be zero.

```ts
var str = module.__getString(ptr);
...
```

* **__getArrayBuffer**(ptr: `number`): `ArrayBuffer`<br />
Copies an ArrayBuffer's value from the module's memory.
Copies an ArrayBuffer's value from the module's memory. `ptr` must not be zero.

* **__getArray**(ptr: `number`): `number[]`<br />
Copies an array's values from the module's memory. Infers the array type from RTTI.
Copies an array's values from the module's memory. Infers the array type from RTTI. `ptr` must not be zero.

```ts
var arr = module.__getArray(ptr);
Expand All @@ -76,7 +76,7 @@ Besides demangling classes exported from your entry file to a handy object struc
**__getFloat64Array**(ptr: `number`): `Float64Array`

* **__getArrayView**(ptr: `number`): `TypedArray`<br />
Gets a live view on the values of an array in the module's memory. Infers the array type from RTTI.
Gets a live view on the values of an array in the module's memory. Infers the array type from RTTI. `ptr` must not be zero.

This differs from `__getArray` in that the data isn't copied but remains *live* in both directions. That's faster but also unsafe because if the array grows or becomes released, the view will no longer represent the correct memory region and modifying its values in this state will most likely corrupt memory. Use, but use with care.

Expand Down