}
if (to->sa_len > sizeof(ss)) {
- MALLOC(sa, struct sockaddr *, to->sa_len, M_SONAME, M_WAITOK);
+ sa = kheap_alloc(KHEAP_TEMP, to->sa_len, Z_WAITOK);
if (sa == NULL) {
return ENOBUFS;
}
error = sobindlock(sock, sa, 1); /* will lock socket */
if (sa != NULL && want_free == TRUE) {
- FREE(sa, M_SONAME);
+ kheap_free(KHEAP_TEMP, sa, sa->sa_len);
}
return error;
}
if (to->sa_len > sizeof(ss)) {
- MALLOC(sa, struct sockaddr *, to->sa_len, M_SONAME,
- (flags & MSG_DONTWAIT) ? M_NOWAIT : M_WAITOK);
+ sa = kheap_alloc(KHEAP_TEMP, to->sa_len,
+ (flags & MSG_DONTWAIT) ? Z_NOWAIT : Z_WAITOK);
if (sa == NULL) {
return ENOBUFS;
}
socket_unlock(sock, 1);
if (sa != NULL && want_free == TRUE) {
- FREE(sa, M_SONAME);
+ kheap_free(KHEAP_TEMP, sa, sa->sa_len);
}
return error;
if (error == 0 && *psa == NULL) {
error = ENOMEM;
- } else if (error != 0 && *psa != NULL) {
+ } else if (error != 0) {
FREE(*psa, M_SONAME);
- *psa = NULL;
}
return error;
}
void
sock_freeaddr(struct sockaddr *sa)
{
- if (sa != NULL) {
- FREE(sa, M_SONAME);
- }
+ FREE(sa, M_SONAME);
}
errno_t
if (control != NULL) {
m_freem(control);
}
- if (fromsa != NULL) {
- FREE(fromsa, M_SONAME);
- }
+ FREE(fromsa, M_SONAME);
return error;
}