diff options
Diffstat (limited to 'otherlibs/unix/getaddrinfo.c')
-rw-r--r-- | otherlibs/unix/getaddrinfo.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/otherlibs/unix/getaddrinfo.c b/otherlibs/unix/getaddrinfo.c index 4b2cd6e3a4..77a419c8dc 100644 --- a/otherlibs/unix/getaddrinfo.c +++ b/otherlibs/unix/getaddrinfo.c @@ -46,12 +46,12 @@ static value convert_addrinfo(struct addrinfo * a) memcpy(&sa.s_gen, a->ai_addr, len); vaddr = alloc_sockaddr(&sa, len, -1); vcanonname = caml_copy_string(a->ai_canonname == NULL ? "" : a->ai_canonname); - vres = caml_alloc_small(5, 0); - Field(vres, 0) = cst_to_constr(a->ai_family, socket_domain_table, 3, 0); - Field(vres, 1) = cst_to_constr(a->ai_socktype, socket_type_table, 4, 0); - Field(vres, 2) = Val_int(a->ai_protocol); - Field(vres, 3) = vaddr; - Field(vres, 4) = vcanonname; + vres = caml_alloc_5(0, + cst_to_constr(a->ai_family, socket_domain_table, 3, 0), + cst_to_constr(a->ai_socktype, socket_type_table, 4, 0), + Val_int(a->ai_protocol), + vaddr, + vcanonname); CAMLreturn(vres); } @@ -117,9 +117,7 @@ CAMLprim value unix_getaddrinfo(value vnode, value vserv, value vopts) if (retcode == 0) { for (r = res; r != NULL; r = r->ai_next) { e = convert_addrinfo(r); - v = caml_alloc_small(2, 0); - Field(v, 0) = e; - Field(v, 1) = vres; + v = caml_alloc_2(0, e, vres); vres = v; } freeaddrinfo(res); |