static int iconv_xlat_close(void *data) { struct iconv_xlat *dp = data; dp->d_csp->cp_refcount--; kobj_delete((struct kobj*)data, M_ICONV); return 0; }
static int iconv_xlat16_close(void *data) { struct iconv_xlat16 *dp = data; if (dp->f_ctp && dp->f_ctp != data) iconv_close(dp->f_ctp); if (dp->t_ctp && dp->t_ctp != data) iconv_close(dp->t_ctp); dp->d_csp->cp_refcount--; kobj_delete((struct kobj*)data, M_ICONV); return (0); }
static int iconv_ucs_close(void *data) { struct iconv_ucs *dp = data; if (dp->f_ctp) iconv_close(dp->f_ctp); if (dp->t_ctp) iconv_close(dp->t_ctp); if (dp->ctype) iconv_close(dp->ctype); if (dp->d_cspf) dp->d_cspf->cp_refcount--; else if (dp->convtype & (KICONV_UCS_FROM_UTF8 | KICONV_UCS_FROM_LE)) dp->d_csp->cp_refcount--; if (dp->convtype & (KICONV_UCS_TO_UTF8 | KICONV_UCS_TO_LE)) dp->d_csp->cp_refcount--; kobj_delete((struct kobj*)data, M_ICONV); return 0; }
/** * Allocate and return a new device enumeration table parser. * * @param cls The parser class for which an instance will be * allocated. * @param parent The parent device from which EROM resources should * be allocated. * @param rid The resource ID to be used when allocating EROM * resources. * @param cid The device's chip identifier. * * @retval non-NULL success * @retval NULL if an error occured allocating or initializing the * EROM parser. */ bhnd_erom_t * bhnd_erom_alloc(bhnd_erom_class_t *cls, const struct bhnd_chipid *cid, device_t parent, int rid) { bhnd_erom_t *erom; int error; erom = (bhnd_erom_t *)kobj_create((kobj_class_t)cls, M_BHND, M_WAITOK|M_ZERO); if ((error = BHND_EROM_INIT(erom, cid, parent, rid))) { printf("error initializing %s parser at %#jx with " "rid %d: %d\n", cls->name, (uintmax_t)cid->enum_addr, rid, error); kobj_delete((kobj_t)erom, M_BHND); return (NULL); } return (erom); }
/** * Release all resources held by a @p erom parser previously * allocated via bhnd_erom_alloc(). * * @param erom An erom parser instance previously allocated via * bhnd_erom_alloc(). */ void bhnd_erom_free(bhnd_erom_t *erom) { BHND_EROM_FINI(erom); kobj_delete((kobj_t)erom, M_BHND); }