diff options
author | Sverker Eriksson <[email protected]> | 2016-02-18 15:59:56 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-02-18 15:59:56 +0100 |
commit | eae8965a58b049cef1562b4462b05d9cab5286c3 (patch) | |
tree | 2efb7416fadd4820d7d8f1a83cf16d3d73d5744f /erts/emulator/beam/utils.c | |
parent | 85d2337de76ba43f087478d4566641d632f06fec (diff) | |
parent | 7a319cd96f7f4869300b32442ebe892ae557f41c (diff) | |
download | otp-eae8965a58b049cef1562b4462b05d9cab5286c3.tar.gz otp-eae8965a58b049cef1562b4462b05d9cab5286c3.tar.bz2 otp-eae8965a58b049cef1562b4462b05d9cab5286c3.zip |
Merge branch 'sverk/fix-list-length-int/OTP-13288'
* sverk/fix-list-length-int/OTP-13288:
erts: Fix error cases in enif_get_list_length
erts: Use Sint instead of int for list lengths
Diffstat (limited to 'erts/emulator/beam/utils.c')
-rw-r--r-- | erts/emulator/beam/utils.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index 6aad1ff778..3ba02023a1 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -317,10 +317,10 @@ erl_grow_equeue(ErtsEQueue* q, Eterm* default_equeue) * Calculate length of a list. * Returns -1 if not a proper list (i.e. not terminated with NIL) */ -int +Sint erts_list_length(Eterm list) { - int i = 0; + Sint i = 0; while(is_list(list)) { i++; @@ -3930,11 +3930,11 @@ void bin_write(int to, void *to_arg, byte* buf, size_t sz) /* Fill buf with the contents of bytelist list return number of chars in list or -1 for error */ -int -intlist_to_buf(Eterm list, char *buf, int len) +Sint +intlist_to_buf(Eterm list, char *buf, Sint len) { Eterm* listptr; - int sz = 0; + Sint sz = 0; if (is_nil(list)) return 0; @@ -4481,11 +4481,12 @@ int erts_iolist_size(Eterm obj, ErlDrvSizeT* sizep) return iolist_size(0, NULL, obj, sizep); } -/* return 0 if item is not a non-empty flat list of bytes */ -int +/* return 0 if item is not a non-empty flat list of bytes + otherwise return the nonzero length of the list */ +Sint is_string(Eterm list) { - int len = 0; + Sint len = 0; while(is_list(list)) { Eterm* consp = list_val(list); |