From 933304e3dcce052eff6d36c37b708949e53597c3 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Wed, 28 Apr 2010 10:21:36 +0000 Subject: OTP-8474 NIF improvements after R13B04 New NIF API function enif_make_new_binary --- erts/doc/src/erl_nif.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'erts/doc/src') diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml index 18b340591c..5ec844e2ad 100644 --- a/erts/doc/src/erl_nif.xml +++ b/erts/doc/src/erl_nif.xml @@ -163,6 +163,8 @@ ok enif_make_binary. But it does not have to happen in the same NIF call. Read-only binaries do not have to be released.

+

enif_make_new_binary + can be used as a shortcut to allocate and return a binary in the same NIF call.

Binaries are sequences of whole bytes. Bitstrings with an arbitrary bit length have no support yet.

@@ -660,6 +662,16 @@ typedef enum { Create an integer term from a long int

Create an integer term from a long int.

+ unsigned char*enif_make_new_binary(ErlNifEnv* env, unsigned size, ERL_NIF_TERM* termp) + Allocate and create a new binary term +

Allocate a binary of size size bytes and create an owning + term. The binary data is mutable until the calling NIF returns. This is a + quick way to create a new binary without having to use + ErlNifBinary. The drawbacks are + that the binary can not be kept between NIF calls and it can not be + reallocated.

Return a pointer to the raw binary data and set + *termp to the binary term.

+
ERL_NIF_TERMenif_make_ref(ErlNifEnv* env) Create a reference.

Create a reference like erlang:make_ref/0.

-- cgit v1.2.3