From dc47b560f0d0ba67fffd083eb79be8797f970012 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 7 May 2010 18:18:26 +0200 Subject: erl_nif: add make_atom_len, make_existing_atom_len and make_string_len Add new NIF API functions - enif_make_atom_len - enif_make_existing_atom_len - enif_make_string_len These are basically the same as enif_make_atom, enif_make_existing_atom and enif_make_string except that the new functions require a length parameter instead of a null-terminated C-string. Signed-off-by: Tuncer Ayaz --- erts/doc/src/erl_nif.xml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'erts/doc/src') diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml index dc68eb5e5e..03bd42d3b1 100644 --- a/erts/doc/src/erl_nif.xml +++ b/erts/doc/src/erl_nif.xml @@ -618,8 +618,14 @@ typedef enum { ERL_NIF_TERMenif_make_atom(ErlNifEnv* env, const char* name) Create an atom term -

Create an atom term from the C-string name. Unlike other terms, atom - terms may be saved and used between NIF calls.

+

Create an atom term from the null-terminated C-string name. + Unlike other terms, atom terms may be saved and used between NIF calls.

+
+ ERL_NIF_TERMenif_make_atom_len(ErlNifEnv* env, const char* name, size_t len) + Create an atom term +

Create an atom term from the string name with length len. + Null-characters are treated as any other characters. + Unlike other terms, atom terms may be saved and used between NIF calls.

ERL_NIF_TERMenif_make_badarg(ErlNifEnv* env) Make a badarg exception. @@ -639,10 +645,17 @@ typedef enum { intenif_make_existing_atom(ErlNifEnv* env, const char* name, ERL_NIF_TERM* atom) Create an existing atom term

Try to create the term of an already existing atom from - the C-string name. If the atom already exist store the + the null-terminated C-string name. If the atom already exists store the term in *atom and return true, otherwise return false.

+ intenif_make_existing_atom_len(ErlNifEnv* env, const char* name, size_t len, ERL_NIF_TERM* atom) + Create an existing atom term +

Try to create the term of an already existing atom from the + string name with length len. Null-characters are treated + as any other characters. If the atom already exists store the term + in *atom and return true, otherwise return false.

+
ERL_NIF_TERMenif_make_int(ErlNifEnv* env, int i) Create an integer term

Create an integer term.

@@ -711,6 +724,12 @@ typedef enum {

Create a list containing the characters of the null-terminated string string with encoding encoding.

+ ERL_NIF_TERMenif_make_string_len(ErlNifEnv* env, const char* string, size_t len, ErlNifCharEncoding encoding) + Create a string. +

Create a list containing the characters of the string string with + length len and encoding encoding. + Null-characters are treated as any other characters.

+
ERL_NIF_TERMenif_make_sub_binary(ErlNifEnv* env, ERL_NIF_TERM bin_term, unsigned pos, unsigned size) Make a subbinary term. -- cgit v1.2.3