diff options
author | Micael Karlberg <[email protected]> | 2018-06-20 12:33:18 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2018-09-18 14:50:18 +0200 |
commit | 6632cb103336786f3ca12f9d1f1d3338fc76c237 (patch) | |
tree | e756e471b64e5a4a6790c4e5c999a76aa3467c19 /erts/emulator/nifs/common/socket_util.c | |
parent | 44cfb3d222ba4d20607af7cc654746f84ece3989 (diff) | |
download | otp-6632cb103336786f3ca12f9d1f1d3338fc76c237.tar.gz otp-6632cb103336786f3ca12f9d1f1d3338fc76c237.tar.bz2 otp-6632cb103336786f3ca12f9d1f1d3338fc76c237.zip |
[net-nif] Changed return type of getaddrinfo
The returned address info was supposed to be a map,
by was instead (still) a record.
OTP-14831
Diffstat (limited to 'erts/emulator/nifs/common/socket_util.c')
-rw-r--r-- | erts/emulator/nifs/common/socket_util.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/erts/emulator/nifs/common/socket_util.c b/erts/emulator/nifs/common/socket_util.c index 397f69f58d..5014688852 100644 --- a/erts/emulator/nifs/common/socket_util.c +++ b/erts/emulator/nifs/common/socket_util.c @@ -890,7 +890,7 @@ char* esock_decode_type(ErlNifEnv* env, -/* +++ esock_decode_domain +++ +/* +++ esock_decode_type +++ * * Encode the native type to the Erlang form, that is: * @@ -1038,6 +1038,47 @@ char* esock_decode_protocol(ErlNifEnv* env, +/* *** esock_decode_string *** + * + * Decode a string value. A successful decode results in an + * allocation of the string, which the caller has to free + * once the string has been used. + */ +extern +BOOLEAN_T esock_decode_string(ErlNifEnv* env, + const ERL_NIF_TERM eString, + char** stringP) +{ + BOOLEAN_T result; + unsigned int len; + char* bufP; + + if (!GET_LIST_LEN(env, eString, &len) && (len != 0)) { + *stringP = NULL; + result = FALSE; + } else { + + UDBG( ("SUTIL", "esock_decode_string -> len: %d\r\n", len) ); + + bufP = MALLOC(len + 1); // We shall NULL-terminate + + if (GET_STR(env, eString, bufP, len+1)) { + UDBG( ("SUTIL", "esock_decode_string -> buf: %s\r\n", bufP) ); + // bufP[len] = '\0'; + *stringP = bufP; + result = TRUE; + } else { + *stringP = NULL; + result = FALSE; + FREE(bufP); + } + } + + return result; +} + + + /* *** esock_decode_bool *** * * Decode a boolean value. |