}
DEVFS_UNLOCK();
- MALLOC(new_ptmx_ioctl, struct ptmx_ioctl *, sizeof(struct ptmx_ioctl), M_TTYS, M_WAITOK | M_ZERO);
+ new_ptmx_ioctl = kheap_alloc(KM_TTYS, sizeof(struct ptmx_ioctl),
+ Z_WAITOK | Z_ZERO);
if (new_ptmx_ioctl == NULL) {
return NULL;
}
if ((new_ptmx_ioctl->pt_tty = ttymalloc()) == NULL) {
- FREE(new_ptmx_ioctl, M_TTYS);
+ kheap_free(KM_TTYS, new_ptmx_ioctl, sizeof(struct ptmx_ioctl));
return NULL;
}
if ((_state.pis_total - _state.pis_free) >= ptmx_max) {
ttyfree(new_ptmx_ioctl->pt_tty);
DEVFS_UNLOCK();
- FREE(new_ptmx_ioctl, M_TTYS);
+ kheap_free(KM_TTYS, new_ptmx_ioctl, sizeof(struct ptmx_ioctl));
return NULL;
}
if (_state.pis_free == 0) {
struct ptmx_ioctl **new_pis_ioctl_list;
struct ptmx_ioctl **old_pis_ioctl_list = NULL;
+ size_t old_pis_total = 0;
/* Yes. */
- MALLOC(new_pis_ioctl_list, struct ptmx_ioctl **, sizeof(struct ptmx_ioctl *) * (_state.pis_total + PTMX_GROW_VECTOR), M_TTYS, M_WAITOK | M_ZERO);
+ new_pis_ioctl_list = kheap_alloc(KM_TTYS,
+ sizeof(struct ptmx_ioctl *) * (_state.pis_total + PTMX_GROW_VECTOR),
+ Z_WAITOK | Z_ZERO);
if (new_pis_ioctl_list == NULL) {
ttyfree(new_ptmx_ioctl->pt_tty);
DEVFS_UNLOCK();
- FREE(new_ptmx_ioctl, M_TTYS);
+ kheap_free(KM_TTYS, new_ptmx_ioctl, sizeof(struct ptmx_ioctl));
return NULL;
}
/* If this is not the first time, copy the old over */
bcopy(_state.pis_ioctl_list, new_pis_ioctl_list, sizeof(struct ptmx_ioctl *) * _state.pis_total);
old_pis_ioctl_list = _state.pis_ioctl_list;
+ old_pis_total = _state.pis_total;
_state.pis_ioctl_list = new_pis_ioctl_list;
_state.pis_free += PTMX_GROW_VECTOR;
_state.pis_total += PTMX_GROW_VECTOR;
- if (old_pis_ioctl_list) {
- FREE(old_pis_ioctl_list, M_TTYS);
- }
+ kheap_free(KM_TTYS, old_pis_ioctl_list,
+ sizeof(struct ptmx_ioctl *) * old_pis_total);
}
/* is minor in range now? */
if (minor < 0 || minor >= _state.pis_total) {
ttyfree(new_ptmx_ioctl->pt_tty);
DEVFS_UNLOCK();
- FREE(new_ptmx_ioctl, M_TTYS);
+ kheap_free(KM_TTYS, new_ptmx_ioctl, sizeof(struct ptmx_ioctl));
return NULL;
}
if (_state.pis_ioctl_list[minor] != NULL) {
ttyfree(new_ptmx_ioctl->pt_tty);
DEVFS_UNLOCK();
- FREE(new_ptmx_ioctl, M_TTYS);
+ kheap_free(KM_TTYS, new_ptmx_ioctl, sizeof(struct ptmx_ioctl));
/* Special error value so we know to redrive the open, we've been raced */
return (struct ptmx_ioctl*)-1;
devfs_remove(old_ptmx_ioctl->pt_devhandle);
}
ttyfree(old_ptmx_ioctl->pt_tty);
- FREE(old_ptmx_ioctl, M_TTYS);
+ kheap_free(KM_TTYS, old_ptmx_ioctl, sizeof(struct ptmx_ioctl));
}
return 0; /* Success */