mruby-socket/socket.c: use z! argument specifier rather than o

`z!` specifier checks if the argument is NULL terminated string or nil.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-08-09 14:20:18 +09:00
parent 9d370e0851
commit 10ed2ea03b
+3 -13
View File
@@ -131,24 +131,14 @@ static mrb_value
mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass)
{
struct addrinfo hints = {0}, *res0;
mrb_value family, nodename, protocol, service, socktype;
mrb_value family, protocol, service, socktype;
mrb_int flags;
int error;
const char *hostname = NULL, *servname = NULL;
const char *hostname, *servname = NULL;
family = socktype = protocol = mrb_nil_value();
flags = 0;
mrb_get_args(mrb, "oo|oooi", &nodename, &service, &family, &socktype, &protocol, &flags);
if (mrb_string_p(nodename)) {
hostname = RSTRING_CSTR(mrb, nodename);
}
else if (mrb_nil_p(nodename)) {
hostname = NULL;
}
else {
mrb_raise(mrb, E_TYPE_ERROR, "nodename must be String or nil");
}
mrb_get_args(mrb, "z!o|oooi", &hostname, &service, &family, &socktype, &protocol, &flags);
if (mrb_string_p(service)) {
servname = RSTRING_CSTR(mrb, service);