Moved the knowledge of default upcase size to unistr.c

This commit is contained in:
Jean-Pierre André 2011-02-08 13:52:12 +01:00
parent b0849af206
commit 4c6cf9d977
3 changed files with 25 additions and 6 deletions

View File

@ -61,6 +61,7 @@ extern char *ntfs_uppercase_mbs(const char *low,
const ntfschar *upcase, u32 upcase_len);
extern void ntfs_upcase_table_build(ntfschar *uc, u32 uc_len);
extern u32 ntfs_upcase_build_default(ntfschar **upcase);
extern ntfschar *ntfs_locase_table_build(const ntfschar *uc, u32 uc_cnt);
extern ntfschar *ntfs_str2ucs(const char *s, int *len);

View File

@ -1251,6 +1251,27 @@ void ntfs_upcase_table_build(ntfschar *uc, u32 uc_len)
}
}
/*
* Allocate and build the default upcase table
*
* Returns the number of entries
* 0 if failed
*/
#define UPCASE_LEN 65536 /* default number of entries in upcase */
u32 ntfs_upcase_build_default(ntfschar **upcase)
{
u32 upcase_len;
*upcase = (ntfschar*)ntfs_malloc(UPCASE_LEN*2);
if (*upcase) {
ntfs_upcase_table_build(*upcase, UPCASE_LEN*2);
upcase_len = UPCASE_LEN;
}
return (upcase_len);
}
/*
* Build a table for converting to lower case
*

View File

@ -482,13 +482,10 @@ ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev, unsigned long flags)
goto error_exit;
/* Create the default upcase table. */
vol->upcase_len = 65536;
vol->upcase = ntfs_malloc(vol->upcase_len * sizeof(ntfschar));
if (!vol->upcase)
vol->upcase_len = ntfs_upcase_build_default(&vol->upcase);
if (!vol->upcase_len || !vol->upcase)
goto error_exit;
ntfs_upcase_table_build(vol->upcase,
vol->upcase_len * sizeof(ntfschar));
/* Default with no locase table and case sensitive file names */
vol->locase = (ntfschar*)NULL;
NVolSetCaseSensitive(vol);