/* * Generate an OEM name for the given share name. If the name is * shorter than 13 bytes the oemname will be returned; otherwise NULL * is returned. */ static char * smb_kshare_oemname(const char *shrname) { smb_wchar_t *unibuf; char *oem_name; int length; length = strlen(shrname) + 1; oem_name = smb_mem_alloc(length); unibuf = smb_mem_alloc(length * sizeof (smb_wchar_t)); (void) smb_mbstowcs(unibuf, shrname, length); if (ucstooem(oem_name, unibuf, length, OEM_CPG_850) == 0) (void) strcpy(oem_name, shrname); smb_mem_free(unibuf); if (strlen(oem_name) + 1 > SMB_SHARE_OEMNAME_MAX) { smb_mem_free(oem_name); return (NULL); } return (oem_name); }
static void smb_ofile_netinfo_fini(smb_netfileinfo_t *fi) { if (fi == NULL) return; if (fi->fi_path) smb_mem_free(fi->fi_path); if (fi->fi_username) kmem_free(fi->fi_username, fi->fi_namelen); bzero(fi, sizeof (smb_netfileinfo_t)); }
/* * Frees all the memory allocated for the given * share structure. It also removes the structure * from the share cache. */ static void smb_kshare_destroy(void *p) { smb_kshare_t *shr = (smb_kshare_t *)p; ASSERT(shr); ASSERT(shr->shr_magic == SMB_SHARE_MAGIC); smb_mem_free(shr->shr_name); smb_mem_free(shr->shr_path); smb_mem_free(shr->shr_cmnt); smb_mem_free(shr->shr_container); smb_mem_free(shr->shr_oemname); smb_mem_free(shr->shr_access_none); smb_mem_free(shr->shr_access_ro); smb_mem_free(shr->shr_access_rw); kmem_cache_free(smb_kshare_cache_share, shr); }