From 951b8c9076cc9a5283483633052587984274b8aa Mon Sep 17 00:00:00 2001
From: Sverker Eriksson
Date: Wed, 27 May 2015 17:53:59 +0200
Subject: erts: Rename ErlNifMapIteratorEntry enums
To differentiate between first/last map entry
and head/tail which is before/after first/last map entry.
---
erts/emulator/beam/erl_nif.c | 8 ++++----
erts/emulator/beam/erl_nif.h | 8 ++++++--
erts/emulator/test/nif_SUITE_data/nif_SUITE.c | 4 ++--
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 426a00304e..4df34e4a06 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -2024,8 +2024,8 @@ int enif_map_iterator_create(ErlNifEnv *env,
size_t offset;
switch (entry) {
- case ERL_NIF_MAP_ITERATOR_HEAD: offset = 0; break;
- case ERL_NIF_MAP_ITERATOR_TAIL: offset = flatmap_get_size(mp) - 1; break;
+ case ERL_NIF_MAP_ITERATOR_FIRST: offset = 0; break;
+ case ERL_NIF_MAP_ITERATOR_LAST: offset = flatmap_get_size(mp) - 1; break;
default: goto error;
}
@@ -2048,12 +2048,12 @@ int enif_map_iterator_create(ErlNifEnv *env,
WSTACK_INIT(iter->u.hash.wstack, ERTS_ALC_T_NIF);
switch (entry) {
- case ERL_NIF_MAP_ITERATOR_HEAD:
+ case ERL_NIF_MAP_ITERATOR_FIRST:
iter->idx = 1;
hashmap_iterator_init(&iter->u.hash.wstack->ws, map, 0);
iter->u.hash.kv = hashmap_iterator_next(&iter->u.hash.wstack->ws);
break;
- case ERL_NIF_MAP_ITERATOR_TAIL:
+ case ERL_NIF_MAP_ITERATOR_LAST:
iter->idx = hashmap_size(map);
hashmap_iterator_init(&iter->u.hash.wstack->ws, map, 1);
iter->u.hash.kv = hashmap_iterator_prev(&iter->u.hash.wstack->ws);
diff --git a/erts/emulator/beam/erl_nif.h b/erts/emulator/beam/erl_nif.h
index c4fdfd4187..af806736fd 100644
--- a/erts/emulator/beam/erl_nif.h
+++ b/erts/emulator/beam/erl_nif.h
@@ -218,8 +218,12 @@ typedef struct /* All fields all internal and may change */
} ErlNifMapIterator;
typedef enum {
- ERL_NIF_MAP_ITERATOR_HEAD = 1,
- ERL_NIF_MAP_ITERATOR_TAIL = 2
+ ERL_NIF_MAP_ITERATOR_FIRST = 1,
+ ERL_NIF_MAP_ITERATOR_LAST = 2,
+
+ /* deprecated synonyms (undocumented in 17 and 18-rc) */
+ ERL_NIF_MAP_ITERATOR_HEAD = ERL_NIF_MAP_ITERATOR_FIRST,
+ ERL_NIF_MAP_ITERATOR_TAIL = ERL_NIF_MAP_ITERATOR_LAST
} ErlNifMapIteratorEntry;
#if (defined(__WIN32__) || defined(_WIN32) || defined(_WIN32_))
diff --git a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
index 3cc9f51ef8..d964ae338e 100644
--- a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
+++ b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c
@@ -1802,7 +1802,7 @@ static ERL_NIF_TERM sorted_list_from_maps_nif(ErlNifEnv* env, int argc, const ER
if (argc != 1 && !enif_is_map(env, map))
return enif_make_int(env, __LINE__);
- if(!enif_map_iterator_create(env, map, &iter_f, ERL_NIF_MAP_ITERATOR_HEAD))
+ if(!enif_map_iterator_create(env, map, &iter_f, ERL_NIF_MAP_ITERATOR_FIRST))
return enif_make_int(env, __LINE__);
cnt = 0;
@@ -1817,7 +1817,7 @@ static ERL_NIF_TERM sorted_list_from_maps_nif(ErlNifEnv* env, int argc, const ER
if (cnt && next_ret)
return enif_make_int(env, __LINE__);
- if(!enif_map_iterator_create(env, map, &iter_b, ERL_NIF_MAP_ITERATOR_TAIL))
+ if(!enif_map_iterator_create(env, map, &iter_b, ERL_NIF_MAP_ITERATOR_LAST))
return enif_make_int(env, __LINE__);
cnt = 0;
--
cgit v1.2.3
From 264c4d037618a5ca8f55001855cb422d0bb5d136 Mon Sep 17 00:00:00 2001
From: Sverker Eriksson
Date: Wed, 27 May 2015 17:55:08 +0200
Subject: erts: Add docs for map functions in nif API
---
erts/doc/src/erl_nif.xml | 129 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 121 insertions(+), 8 deletions(-)
diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml
index 4bad8b253c..2cc06de0e0 100644
--- a/erts/doc/src/erl_nif.xml
+++ b/erts/doc/src/erl_nif.xml
@@ -461,8 +461,9 @@ ok
independent environment with all its terms is valid until you explicitly
invalidates it with enif_free_env
or enif_send.
- All elements of a list/tuple must belong to the same environment as the
- list/tuple itself. Terms can be copied between environments with
+
All contained terms of a list/tuple/map must belong to the same
+ environment as the list/tuple/map itself. Terms can be copied between
+ environments with
enif_make_copy.
ErlNifFunc
@@ -729,7 +730,18 @@ typedef enum {
return true, or return false if term is not an integer or is
outside the bounds of type long int.
- intenif_get_resource(ErlNifEnv* env, ERL_NIF_TERM term, ErlNifResourceType* type, void** objp)
+ intenif_get_map_size(ErlNifEnv* env, ERL_NIF_TERM term, size_t *size)
+ Read the size of a map term
+ Set *size to the number of key-value pairs in the map term and
+ return true, or return false if term is not a map.
+
+ intenif_get_map_value(ErlNifEnv* env, ERL_NIF_TERM map, ERL_NIF_TERM key, ERL_NIF_TERM* value)
+ Get the value of a key in a map
+ Set *value to the value associated with key in the
+ map map and return true. Return false if map is not a map
+ or if map does not contain key.
+
+ intenif_get_resource(ErlNifEnv* env, ERL_NIF_TERM term, ErlNifResourceType* type, void** objp)
Get the pointer to a resource object
Set *objp to point to the resource object referred to by term.
Return true on success or false if term is not a handle to a resource object
@@ -817,6 +829,10 @@ typedef enum {
Determine if a term is an exception
Return true if term is an exception.
+ intenif_is_map(ErlNifEnv* env, ERL_NIF_TERM term)
+ Determine if a term is a map
+ Return true if term is a map, false otherwise.
+
intenif_is_number(ErlNifEnv* env, ERL_NIF_TERM term)
Determine if a term is a number (integer or float)
Return true if term is a number.
@@ -986,12 +1002,13 @@ typedef enum {
Create an ordinary list containing the elements of array arr
of length cnt. An empty list is returned if cnt is 0.
- intenif_make_reverse_list(ErlNifEnv* env, ERL_NIF_TERM term, ERL_NIF_TERM *list)
- Create the reverse list of the list term.
- Set *list to the reverse list of the list term and return true,
- or return false if term is not a list. This function should only be used on
+ intenif_make_reverse_list(ErlNifEnv* env, ERL_NIF_TERM list_in, ERL_NIF_TERM *list_out)
+ Create the reverse of a list
+ Set *list_out to the reverse list of the list list_in and return true,
+ or return false if list_in is not a list. This function should only be used on
short lists as a copy will be created of the list which will not be released until after the
- nif returns.
+ nif returns.
+ The list_in term must belong to the environment env.
ERL_NIF_TERMenif_make_long(ErlNifEnv* env, long int i)
Create an integer term from a long int
@@ -1007,6 +1024,36 @@ typedef enum {
reallocated.Return a pointer to the raw binary data and set
*termp to the binary term.
+ ERL_NIF_TERMenif_make_new_map(ErlNifEnv* env)
+ Make an empty map term
+ Make an empty map term.
+
+ intenif_make_map_put(ErlNifEnv* env, ERL_NIF_TERM map_in, ERL_NIF_TERM key, ERL_NIF_TERM value, ERL_NIF_TERM* map_out)
+ Insert key-value pair in map
+ Make a copy of map map_in and insert key with
+ value. If key already exists in map_in, the old
+ associated value is replaced by value. If successful set
+ *map_out to the new map and return true. Return false if
+ map_in is not a map.
+ The map_in term must belong to the environment env.
+
+ intenif_make_map_update(ErlNifEnv* env, ERL_NIF_TERM map_in, ERL_NIF_TERM key, ERL_NIF_TERM new_value, ERL_NIF_TERM* map_out)
+ Replace value for key in map
+ Make a copy of map map_in and replace the old associated
+ value for key with new_value. If successful set
+ *map_out to the new map and return true. Return false if
+ map_in is not a map or if it does no contain key.
+ The map_in term must belong to the environment env.
+
+ intenif_make_map_remove(ErlNifEnv* env, ERL_NIF_TERM map_in, ERL_NIF_TERM key, ERL_NIF_TERM* map_out)
+ Remove key from map
+ If map map_in contains key, make a copy of
+ map_in in *map_out and remove key and associated
+ value. If map map_in does not contain key, set
+ *map_out to map_in. Return true for success or false if
+ map_in is not a map.
+ The map_in term must belong to the environment env.
+
ERL_NIF_TERMenif_make_pid(ErlNifEnv* env, const ErlNifPid* pid)
Make a pid term
Make a pid term from *pid.
@@ -1108,6 +1155,72 @@ typedef enum {
Create an integer term from an unsigned long int
Create an integer term from an unsigned long int.
+ intenif_map_iterator_create(ErlNifEnv *env, ERL_NIF_TERM map, ErlNifMapIterator *iter, ErlNifMapIteratorEntry entry)
+ Create a map iterator
+ Create an iterator for the map map by initializing the
+ structure pointed to by iter. The entry argument determines
+ the start position of the iterator: ERL_NIF_MAP_ITERATOR_FIRST or
+ ERL_NIF_MAP_ITERATOR_LAST. Return true on success or false if
+ map is not a map.
+ A map iterator is only useful during the lifetime of the environment
+ env that the map belongs to. The iterator must be destroyed by
+ calling
+ enif_map_iterator_destroy.
+
+ERL_NIF_TERM key, value;
+ErlNifMapIterator iter;
+enif_map_iterator_create(env, my_map, ERL_NIF_MAP_ITERATOR_FIRST);
+
+while (enif_map_iterator_get_pair(env, &iter, &key, &value)) {
+ do_something(key,value);
+ enif_map_iterator_next(env, &iter);
+}
+enif_map_iterator_destroy(env, &iter);
+
+ The key-value pairs of a map have no defined iteration
+ order. The only guarantee is that the iteration order of a single map
+ instance is preserved during the lifetime of the environment that the map
+ belongs to.
+
+
+
+ voidenif_map_iterator_destroy(ErlNifEnv *env, ErlNifMapIterator *iter)
+ Destroy a map iterator
+ Destroy a map iterator created by
+ enif_map_iterator_create.
+
+
+ intenif_map_iterator_get_pair(ErlNifEnv *env, ErlNifMapIterator *iter, ERL_NIF_TERM *key, ERL_NIF_TERM *value)
+ Get key and value at current map iterator position
+ Get key and value terms at current map iterator position.
+ On success set *key and *value and return true.
+ Return false if the iterator is positioned at head (before first entry)
+ or tail (beyond last entry).
+
+ intenif_map_iterator_is_head(ErlNifEnv *env, ErlNifMapIterator *iter)
+ Check if map iterator is positioned before first
+ Return true if map iterator iter is positioned
+ before first entry.
+
+ intenif_map_iterator_is_tail(ErlNifEnv *env, ErlNifMapIterator *iter)
+ Check if map iterator is positioned after last
+ Return true if map iterator iter is positioned
+ after last entry.
+
+ intenif_map_iterator_next(ErlNifEnv *env, ErlNifMapIterator *iter)
+ Increment map iterator to point to next entry
+ Increment map iterator to point to next key-value entry.
+ Return true if the iterator is now positioned at a valid key-value entry,
+ or false if the iterator is positioned at the tail (beyond the last
+ entry).
+
+ intenif_map_iterator_prev(ErlNifEnv *env, ErlNifMapIterator *iter)
+ Decrement map iterator to point to previous entry
+ Decrement map iterator to point to previous key-value entry.
+ Return true if the iterator is now positioned at a valid key-value entry,
+ or false if the iterator is positioned at the head (before the first
+ entry).
+
ErlNifMutex *enif_mutex_create(char *name)
Same as erl_drv_mutex_create.
--
cgit v1.2.3
From 7d60e4c592399c2e375a10338015e168a09d16a3 Mon Sep 17 00:00:00 2001
From: Sverker Eriksson
Date: Thu, 28 May 2015 12:30:15 +0200
Subject: erts: Fix alphabetic order in erl_nif doc
enif_make_reverse_list was at the wrong place
---
erts/doc/src/erl_nif.xml | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml
index 2cc06de0e0..6a4fe5f8b7 100644
--- a/erts/doc/src/erl_nif.xml
+++ b/erts/doc/src/erl_nif.xml
@@ -1002,14 +1002,6 @@ typedef enum {
Create an ordinary list containing the elements of array arr
of length cnt. An empty list is returned if cnt is 0.
- intenif_make_reverse_list(ErlNifEnv* env, ERL_NIF_TERM list_in, ERL_NIF_TERM *list_out)
- Create the reverse of a list
- Set *list_out to the reverse list of the list list_in and return true,
- or return false if list_in is not a list. This function should only be used on
- short lists as a copy will be created of the list which will not be released until after the
- nif returns.
- The list_in term must belong to the environment env.
-
ERL_NIF_TERMenif_make_long(ErlNifEnv* env, long int i)
Create an integer term from a long int
Create an integer term from a long int.
@@ -1097,6 +1089,14 @@ typedef enum {
enif_release_resource.
+ intenif_make_reverse_list(ErlNifEnv* env, ERL_NIF_TERM list_in, ERL_NIF_TERM *list_out)
+ Create the reverse of a list
+ Set *list_out to the reverse list of the list list_in and return true,
+ or return false if list_in is not a list. This function should only be used on
+ short lists as a copy will be created of the list which will not be released until after the
+ nif returns.
+ The list_in term must belong to the environment env.
+
ERL_NIF_TERMenif_make_string(ErlNifEnv* env, const char* string, ErlNifCharEncoding encoding)
Create a string.
Create a list containing the characters of the
--
cgit v1.2.3
From a519a52617a6a5bbdb8b17bdd892ab012cf8080b Mon Sep 17 00:00:00 2001
From: Sverker Eriksson
Date: Thu, 28 May 2015 12:33:11 +0200
Subject: erts: Cleanup fsummary lines in erl_nif docs
by removing all full stop.
---
erts/doc/src/erl_nif.xml | 64 ++++++++++++++++++++++++------------------------
1 file changed, 32 insertions(+), 32 deletions(-)
diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml
index 6a4fe5f8b7..e915c3b693 100644
--- a/erts/doc/src/erl_nif.xml
+++ b/erts/doc/src/erl_nif.xml
@@ -565,11 +565,11 @@ typedef enum {
void *enif_alloc(size_t size)
- Allocate dynamic memory.
+ Allocate dynamic memory
Allocate memory of size bytes. Return NULL if allocation failed.
intenif_alloc_binary(size_t size, ErlNifBinary* bin)
- Create a new binary.
+ Create a new binary
Allocate a new binary of size size
bytes. Initialize the structure pointed to by bin to
refer to the allocated binary. The binary must either be released by
@@ -596,7 +596,7 @@ typedef enum {
Allocate a memory managed resource object of type type and size size bytes.
voidenif_clear_env(ErlNifEnv* env)
- Clear an environment for reuse.
+ Clear an environment for reuse
Free all terms in an environment and clear it for reuse. The environment must
have been allocated with enif_alloc_env.
@@ -684,14 +684,14 @@ typedef enum {
size-1.
intenif_get_atom_length(ErlNifEnv* env, ERL_NIF_TERM term, unsigned* len, ErlNifCharEncoding encode)
- Get the length of atom term.
+ Get the length of atom term
Set *len to the length (number of bytes excluding
terminating null character) of the atom term with encoding
encode. Return true on success or false if term is not an
atom.
intenif_get_double(ErlNifEnv* env, ERL_NIF_TERM term, double* dp)
- Read a floating-point number term.
+ Read a floating-point number term
Set *dp to the floating point value of
term. Return true on success or false if term is not a float.
@@ -720,12 +720,12 @@ typedef enum {
non-empty list.
intenif_get_list_length(ErlNifEnv* env, ERL_NIF_TERM term, unsigned* len)
- Get the length of list term.
+ Get the length of list term
Set *len to the length of list term and return true,
or return false if term is not a list.
intenif_get_long(ErlNifEnv* env, ERL_NIF_TERM term, long int* ip)
- Read an long integer term.
+ Read an long integer term
Set *ip to the long integer value of term and
return true, or return false if term is not an integer or is
outside the bounds of type long int.
@@ -750,7 +750,7 @@ typedef enum {
intenif_get_string(ErlNifEnv* env,
ERL_NIF_TERM list, char* buf, unsigned size,
ErlNifCharEncoding encode)
- Get a C-string from a list.
+ Get a C-string from a list
Write a null-terminated string, in the buffer pointed to by
buf with size size, consisting of the characters
in the string list. The characters are written using encoding
@@ -763,7 +763,7 @@ typedef enum {
size is less than 1.
intenif_get_tuple(ErlNifEnv* env, ERL_NIF_TERM term, int* arity, const ERL_NIF_TERM** array)
- Inspect the elements of a tuple.
+ Inspect the elements of a tuple
If term is a tuple, set *array to point
to an array containing the elements of the tuple and set
*arity to the number of elements. Note that the array
@@ -773,25 +773,25 @@ typedef enum {
tuple.
intenif_get_uint(ErlNifEnv* env, ERL_NIF_TERM term, unsigned int* ip)
- Read an unsigned integer term.
+ Read an unsigned integer term
Set *ip to the unsigned integer value of term and
return true, or return false if term is not an unsigned integer or
is outside the bounds of type unsigned int.
intenif_get_uint64(ErlNifEnv* env, ERL_NIF_TERM term, ErlNifUInt64* ip)
- Read an unsigned 64-bit integer term.
+ Read an unsigned 64-bit integer term
Set *ip to the unsigned integer value of term and
return true, or return false if term is not an unsigned integer or
is outside the bounds of an unsigned 64-bit integer.
intenif_get_ulong(ErlNifEnv* env, ERL_NIF_TERM term, unsigned long* ip)
- Read an unsigned integer term.
+ Read an unsigned integer term
Set *ip to the unsigned long integer value of term
and return true, or return false if term is not an unsigned integer or is
outside the bounds of type unsigned long.
intenif_has_pending_exception(ErlNifEnv* env)
- Check if an exception has been raised.
+ Check if an exception has been raised
Return true if a pending exception is associated
with the environment env. The only possible exception is currently
badarg (see enif_make_badarg).
@@ -906,7 +906,7 @@ typedef enum {
ERL_NIF_TERMenif_make_badarg(ErlNifEnv* env)
- Make a badarg exception.
+ Make a badarg exception
Make a badarg exception to be returned from a NIF, and associate
it with the environment env. Once a NIF or any function
it calls invokes enif_make_badarg, the runtime ensures that a
@@ -925,14 +925,14 @@ typedef enum {
if enif_make_badarg has been invoked.
ERL_NIF_TERMenif_make_binary(ErlNifEnv* env, ErlNifBinary* bin)
- Make a binary term.
+ Make a binary term
Make a binary term from bin. Any ownership of
the binary data will be transferred to the created term and
bin should be considered read-only for the rest of the NIF
call and then as released.
ERL_NIF_TERMenif_make_copy(ErlNifEnv* dst_env, ERL_NIF_TERM src_term)
- Make a copy of a term.
+ Make a copy of a term
Make a copy of term src_term. The copy will be created in
environment dst_env. The source term may be located in any
environment.
@@ -973,7 +973,7 @@ typedef enum {
Create an integer term from a signed 64-bit integer.
ERL_NIF_TERMenif_make_list(ErlNifEnv* env, unsigned cnt, ...)
- Create a list term.
+ Create a list term
Create an ordinary list term of length cnt. Expects
cnt number of arguments (after cnt) of type ERL_NIF_TERM as the
elements of the list. An empty list is returned if cnt is 0.
@@ -987,18 +987,18 @@ typedef enum {
ERL_NIF_TERMenif_make_list7(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e7)
ERL_NIF_TERMenif_make_list8(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e8)
ERL_NIF_TERMenif_make_list9(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e9)
- Create a list term.
+ Create a list term
Create an ordinary list term with length indicated by the
function name. Prefer these functions (macros) over the variadic
enif_make_list to get a compile time error if the number of
arguments does not match.
ERL_NIF_TERMenif_make_list_cell(ErlNifEnv* env, ERL_NIF_TERM head, ERL_NIF_TERM tail)
- Create a list cell.
+ Create a list cell
Create a list cell [head | tail].
ERL_NIF_TERMenif_make_list_from_array(ErlNifEnv* env, const ERL_NIF_TERM arr[], unsigned cnt)
- Create a list term from an array.
+ Create a list term from an array
Create an ordinary list containing the elements of array arr
of length cnt. An empty list is returned if cnt is 0.
@@ -1051,7 +1051,7 @@ typedef enum {
Make a pid term from *pid.
ERL_NIF_TERMenif_make_ref(ErlNifEnv* env)
- Create a reference.
+ Create a reference
Create a reference like erlang:make_ref/0.
ERL_NIF_TERMenif_make_resource(ErlNifEnv* env, void* obj)
@@ -1098,19 +1098,19 @@ typedef enum {
The list_in term must belong to the environment env.
ERL_NIF_TERMenif_make_string(ErlNifEnv* env, const char* string, ErlNifCharEncoding encoding)
- Create a string.
+ Create a string
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 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, size_t pos, size_t size)
- Make a subbinary term.
+ Make a subbinary term
Make a subbinary of binary bin_term, starting at
zero-based position pos with a length of size bytes.
bin_term must be a binary or bitstring and
@@ -1118,7 +1118,7 @@ typedef enum {
bytes in bin_term.
ERL_NIF_TERMenif_make_tuple(ErlNifEnv* env, unsigned cnt, ...)
- Create a tuple term.
+ Create a tuple term
Create a tuple term of arity cnt. Expects
cnt number of arguments (after cnt) of type ERL_NIF_TERM as the
elements of the tuple.
@@ -1132,14 +1132,14 @@ typedef enum {
ERL_NIF_TERMenif_make_tuple7(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e7)
ERL_NIF_TERMenif_make_tuple8(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e8)
ERL_NIF_TERMenif_make_tuple9(ErlNifEnv* env, ERL_NIF_TERM e1, ..., ERL_NIF_TERM e9)
- Create a tuple term.
+ Create a tuple term
Create a tuple term with length indicated by the
function name. Prefer these functions (macros) over the variadic
enif_make_tuple to get a compile time error if the number of
arguments does not match.
ERL_NIF_TERMenif_make_tuple_from_array(ErlNifEnv* env, const ERL_NIF_TERM arr[], unsigned cnt)
- Create a tuple term from an array.
+ Create a tuple term from an array
Create a tuple containing the elements of array arr
of length cnt.
@@ -1282,18 +1282,18 @@ enif_map_iterator_destroy(env, &iter);
Was previously named enif_get_data.
intenif_realloc_binary(ErlNifBinary* bin, size_t size)
- Change the size of a binary.
+ Change the size of a binary
Change the size of a binary bin. The source binary
may be read-only, in which case it will be left untouched and
a mutable copy is allocated and assigned to *bin. Return true on success,
false if memory allocation failed.
voidenif_release_binary(ErlNifBinary* bin)
- Release a binary.
+ Release a binary
Release a binary obtained from enif_alloc_binary.
voidenif_release_resource(void* obj)
- Release a resource object.
+ Release a resource object
Remove a reference to resource object objobtained from
enif_alloc_resource.
The resource object will be destructed when the last reference is removed.
@@ -1369,12 +1369,12 @@ enif_map_iterator_destroy(env, &iter);
ErlNifPid *enif_self(ErlNifEnv* caller_env, ErlNifPid* pid)
- Get the pid of the calling process.
+ Get the pid of the calling process
Initialize the pid variable *pid to represent the
calling process. Return pid.
intenif_send(ErlNifEnv* env, ErlNifPid* to_pid, ErlNifEnv* msg_env, ERL_NIF_TERM msg)
- Send a message to a process.
+ Send a message to a process
Send a message to a process.
env
--
cgit v1.2.3