diff options
author | Tuncer Ayaz <[email protected]> | 2010-05-07 18:12:05 +0200 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2010-05-24 14:25:13 +0200 |
commit | 8c8663f32f0e9fc2b9483e2b99cee5f703640e88 (patch) | |
tree | b3b191d8230fd664a597c4565be916342cc0b752 /erts/emulator/beam/erl_nif.c | |
parent | 08d67b91c5daf5eb5e8d974ca08bb1b634c4ae2a (diff) | |
download | otp-8c8663f32f0e9fc2b9483e2b99cee5f703640e88.tar.gz otp-8c8663f32f0e9fc2b9483e2b99cee5f703640e88.tar.bz2 otp-8c8663f32f0e9fc2b9483e2b99cee5f703640e88.zip |
erl_nif: add enif_get_atom_length and enif_get_list_length
Add new NIF API functions
- enif_get_atom_length
- enif_get_list_length
Signed-off-by: Tuncer Ayaz <[email protected]>
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r-- | erts/emulator/beam/erl_nif.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index a07aa2e81f..4a3b0ad8ca 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -601,6 +601,15 @@ int enif_get_double(ErlNifEnv* env, Eterm term, double* dp) return 1; } +int enif_get_atom_length(ErlNifEnv* env, Eterm atom, unsigned* len) +{ + Atom* ap; + if (is_not_atom(atom)) return 0; + ap = atom_tab(atom_val(atom)); + *len = ap->len; + return 1; +} + int enif_get_list_cell(ErlNifEnv* env, Eterm term, Eterm* head, Eterm* tail) { Eterm* val; @@ -611,6 +620,13 @@ int enif_get_list_cell(ErlNifEnv* env, Eterm term, Eterm* head, Eterm* tail) return 1; } +int enif_get_list_length(ErlNifEnv* env, Eterm term, unsigned* len) +{ + if (is_not_list(term) && is_not_nil(term)) return 0; + *len = list_length(term); + return 1; +} + ERL_NIF_TERM enif_make_int(ErlNifEnv* env, int i) { #if SIZEOF_INT == ERTS_SIZEOF_ETERM |