aboutsummaryrefslogtreecommitdiffstats
path: root/erts/doc/src/erl_nif.xml
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2018-02-19 19:40:10 +0100
committerJohn Högberg <[email protected]>2018-02-26 08:29:38 +0100
commit165b8455d4bf2e3797008a9ad8496b203d017474 (patch)
tree294d12a84496fdba57ac76de4b1ffc8f9a96ff95 /erts/doc/src/erl_nif.xml
parenta92c200af89b9b1f35db26ae8e13333af5638e15 (diff)
downloadotp-165b8455d4bf2e3797008a9ad8496b203d017474.tar.gz
otp-165b8455d4bf2e3797008a9ad8496b203d017474.tar.bz2
otp-165b8455d4bf2e3797008a9ad8496b203d017474.zip
Suggest using enif_make_new_binary when possible
While enif_make_binary will create heap-binaries from ErlNifBinaries when possible now, enif_alloc_binary still allocates a Binary* off-heap which is avoided entirely with enif_make_new_binary.
Diffstat (limited to 'erts/doc/src/erl_nif.xml')
-rw-r--r--erts/doc/src/erl_nif.xml4
1 files changed, 4 insertions, 0 deletions
diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml
index 23f0c66429..9655fcd994 100644
--- a/erts/doc/src/erl_nif.xml
+++ b/erts/doc/src/erl_nif.xml
@@ -974,6 +974,10 @@ typedef struct {
<seealso marker="#enif_make_binary"><c>enif_make_binary</c></seealso>.
An allocated (and owned) <c>ErlNifBinary</c> can be kept between NIF
calls.</p>
+ <p>If you do not need to reallocate or keep the data alive across NIF
+ calls, consider using <seealso marker="#enif_make_new_binary">
+ <c>enif_make_new_binary</c></seealso> instead as it will allocate
+ small binaries on the process heap when possible.</p>
<p>Returns <c>true</c> on success, or <c>false</c> if allocation
fails.</p>
</desc>