From 165b8455d4bf2e3797008a9ad8496b203d017474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Mon, 19 Feb 2018 19:40:10 +0100 Subject: 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. --- erts/doc/src/erl_nif.xml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'erts/doc') 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 { enif_make_binary. An allocated (and owned) ErlNifBinary can be kept between NIF calls.

+

If you do not need to reallocate or keep the data alive across NIF + calls, consider using + enif_make_new_binary instead as it will allocate + small binaries on the process heap when possible.

Returns true on success, or false if allocation fails.

-- cgit v1.2.3