diff --git a/dlls/usp10/bidi.c b/dlls/usp10/bidi.c index 5adce9d8660..32f3f4028ce 100644 --- a/dlls/usp10/bidi.c +++ b/dlls/usp10/bidi.c @@ -695,8 +695,8 @@ static BracketPair *computeBracketPairs(IsolatedRun *iso_run) int pair_count = 0; int i; - open_stack = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * iso_run->length); - stack_index = HeapAlloc(GetProcessHeap(), 0, sizeof(int) * iso_run->length); + open_stack = heap_alloc(iso_run->length * sizeof(*open_stack)); + stack_index = heap_alloc(iso_run->length * sizeof(*stack_index)); for (i = 0; i < iso_run->length; i++) { @@ -705,7 +705,7 @@ static BracketPair *computeBracketPairs(IsolatedRun *iso_run) { if (!out) { - out = HeapAlloc(GetProcessHeap(),0,sizeof(BracketPair)); + out = heap_alloc(sizeof(*out)); out[0].start = -1; } @@ -995,8 +995,8 @@ static void computeIsolatingRunsSet(unsigned baselevel, WORD *pcls, WORD *pLevel Run *runs; IsolatedRun *current_isolated; - runs = HeapAlloc(GetProcessHeap(), 0, uCount * sizeof(Run)); - if (!runs) return; + if (!(runs = heap_alloc(uCount * sizeof(*runs)))) + return; list_init(set); @@ -1023,8 +1023,9 @@ static void computeIsolatingRunsSet(unsigned baselevel, WORD *pcls, WORD *pLevel { int type_fence, real_end; int j; - current_isolated = HeapAlloc(GetProcessHeap(), 0, sizeof(IsolatedRun) + sizeof(RunChar)*uCount); - if (!current_isolated) break; + + if (!(current_isolated = heap_alloc(FIELD_OFFSET(IsolatedRun, item[uCount])))) + break; run_start = runs[k].start; current_isolated->e = runs[k].e; @@ -1141,8 +1142,7 @@ BOOL BIDI_DetermineLevels( TRACE("%s, %d\n", debugstr_wn(lpString, uCount), uCount); - chartype = HeapAlloc(GetProcessHeap(), 0, uCount * sizeof(WORD)); - if (!chartype) + if (!(chartype = heap_alloc(uCount * sizeof(*chartype)))) { WARN("Out of memory\n"); return FALSE; diff --git a/dlls/usp10/breaking.c b/dlls/usp10/breaking.c index b1220c1bb66..c64a2186ecd 100644 --- a/dlls/usp10/breaking.c +++ b/dlls/usp10/breaking.c @@ -81,8 +81,8 @@ void BREAK_line(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT TRACE("In %s\n",debugstr_wn(chars,count)); - break_class = HeapAlloc(GetProcessHeap(),0, count * sizeof(short)); - break_before = HeapAlloc(GetProcessHeap(),0, count * sizeof(short)); + break_class = heap_alloc(count * sizeof(*break_class)); + break_before = heap_alloc(count * sizeof(*break_before)); for (i = 0; i < count; i++) { diff --git a/dlls/usp10/indic.c b/dlls/usp10/indic.c index 62834d13b90..71c22856cae 100644 --- a/dlls/usp10/indic.c +++ b/dlls/usp10/indic.c @@ -342,7 +342,7 @@ void Indic_ParseSyllables( HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, LPCW if (*syllable_count) *syllables = HeapReAlloc(GetProcessHeap(),0,*syllables, sizeof(IndicSyllable)*(*syllable_count+1)); else - *syllables = HeapAlloc(GetProcessHeap(),0,sizeof(IndicSyllable)); + *syllables = heap_alloc(sizeof(**syllables)); (*syllables)[*syllable_count].start = index; (*syllables)[*syllable_count].base = center; (*syllables)[*syllable_count].ralf = -1; diff --git a/dlls/usp10/opentype.c b/dlls/usp10/opentype.c index 6d6a25e2b2d..e531f3a4986 100644 --- a/dlls/usp10/opentype.c +++ b/dlls/usp10/opentype.c @@ -634,7 +634,7 @@ static VOID *load_CMAP_format12_table(HDC hdc, ScriptCache *psc) length = GetFontData(hdc, CMAP_TAG , 0, NULL, 0); if (length != GDI_ERROR) { - psc->CMAP_Table = HeapAlloc(GetProcessHeap(),0,length); + psc->CMAP_Table = heap_alloc(length); GetFontData(hdc, CMAP_TAG , 0, psc->CMAP_Table, length); TRACE("Loaded cmap table of %i bytes\n",length); } @@ -2763,24 +2763,29 @@ static void GSUB_initialize_feature_cache(LPCVOID table, LoadedLanguage *languag if (language->feature_count) { - language->features = HeapAlloc(GetProcessHeap(),0,sizeof(LoadedFeature)*language->feature_count); + language->features = heap_alloc(language->feature_count * sizeof(*language->features)); feature_list = (const OT_FeatureList*)((const BYTE*)header + GET_BE_WORD(header->FeatureList)); for (i = 0; i < language->feature_count; i++) { + LoadedFeature *loaded_feature = &language->features[i]; const OT_Feature *feature; int j; int index = GET_BE_WORD(lang->FeatureIndex[i]); - language->features[i].tag = MS_MAKE_TAG(feature_list->FeatureRecord[index].FeatureTag[0], feature_list->FeatureRecord[index].FeatureTag[1], feature_list->FeatureRecord[index].FeatureTag[2], feature_list->FeatureRecord[index].FeatureTag[3]); - language->features[i].feature = ((const BYTE*)feature_list + GET_BE_WORD(feature_list->FeatureRecord[index].Feature)); - feature = (const OT_Feature*)language->features[i].feature; - language->features[i].lookup_count = GET_BE_WORD(feature->LookupCount); - language->features[i].lookups = HeapAlloc(GetProcessHeap(),0,sizeof(WORD) * language->features[i].lookup_count); - for (j = 0; j < language->features[i].lookup_count; j++) - language->features[i].lookups[j] = GET_BE_WORD(feature->LookupListIndex[j]); - language->features[i].tableType = FEATURE_GSUB_TABLE; + loaded_feature->tag = MS_MAKE_TAG(feature_list->FeatureRecord[index].FeatureTag[0], + feature_list->FeatureRecord[index].FeatureTag[1], + feature_list->FeatureRecord[index].FeatureTag[2], + feature_list->FeatureRecord[index].FeatureTag[3]); + loaded_feature->feature = ((const BYTE *)feature_list + + GET_BE_WORD(feature_list->FeatureRecord[index].Feature)); + feature = loaded_feature->feature; + loaded_feature->lookup_count = GET_BE_WORD(feature->LookupCount); + loaded_feature->lookups = heap_alloc(loaded_feature->lookup_count * sizeof(*loaded_feature->lookups)); + for (j = 0; j < loaded_feature->lookup_count; ++j) + loaded_feature->lookups[j] = GET_BE_WORD(feature->LookupListIndex[j]); + loaded_feature->tableType = FEATURE_GSUB_TABLE; } } } @@ -2810,22 +2815,27 @@ static void GPOS_expand_feature_cache(LPCVOID table, LoadedLanguage *language) if (language->feature_count) { - language->features = HeapAlloc(GetProcessHeap(),0,sizeof(LoadedFeature)*language->feature_count); + language->features = heap_alloc(language->feature_count * sizeof(*language->features)); for (i = 0; i < language->feature_count; i++) { + LoadedFeature *loaded_feature = &language->features[i]; const OT_Feature *feature; int j; int index = GET_BE_WORD(lang->FeatureIndex[i]); - language->features[i].tag = MS_MAKE_TAG(feature_list->FeatureRecord[index].FeatureTag[0], feature_list->FeatureRecord[index].FeatureTag[1], feature_list->FeatureRecord[index].FeatureTag[2], feature_list->FeatureRecord[index].FeatureTag[3]); - language->features[i].feature = ((const BYTE*)feature_list + GET_BE_WORD(feature_list->FeatureRecord[index].Feature)); - feature = (const OT_Feature*)language->features[i].feature; - language->features[i].lookup_count = GET_BE_WORD(feature->LookupCount); - language->features[i].lookups = HeapAlloc(GetProcessHeap(),0,sizeof(WORD) * language->features[i].lookup_count); - for (j = 0; j < language->features[i].lookup_count; j++) - language->features[i].lookups[j] = GET_BE_WORD(feature->LookupListIndex[j]); - language->features[i].tableType = FEATURE_GPOS_TABLE; + loaded_feature->tag = MS_MAKE_TAG(feature_list->FeatureRecord[index].FeatureTag[0], + feature_list->FeatureRecord[index].FeatureTag[1], + feature_list->FeatureRecord[index].FeatureTag[2], + feature_list->FeatureRecord[index].FeatureTag[3]); + loaded_feature->feature = ((const BYTE *)feature_list + + GET_BE_WORD(feature_list->FeatureRecord[index].Feature)); + feature = loaded_feature->feature; + loaded_feature->lookup_count = GET_BE_WORD(feature->LookupCount); + loaded_feature->lookups = heap_alloc(loaded_feature->lookup_count * sizeof(*loaded_feature->lookups)); + for (j = 0; j < loaded_feature->lookup_count; ++j) + loaded_feature->lookups[j] = GET_BE_WORD(feature->LookupListIndex[j]); + loaded_feature->tableType = FEATURE_GPOS_TABLE; } } } @@ -2835,19 +2845,25 @@ static void GPOS_expand_feature_cache(LPCVOID table, LoadedLanguage *language) for (i = 0; i < count; i++) { + LoadedFeature *loaded_feature; const OT_Feature *feature; int j; int index = GET_BE_WORD(lang->FeatureIndex[i]); int idx = language->feature_count + i; - language->features[idx].tag = MS_MAKE_TAG(feature_list->FeatureRecord[index].FeatureTag[0], feature_list->FeatureRecord[index].FeatureTag[1], feature_list->FeatureRecord[index].FeatureTag[2], feature_list->FeatureRecord[index].FeatureTag[3]); - language->features[idx].feature = ((const BYTE*)feature_list + GET_BE_WORD(feature_list->FeatureRecord[index].Feature)); - feature = (const OT_Feature*)language->features[idx].feature; - language->features[idx].lookup_count = GET_BE_WORD(feature->LookupCount); - language->features[idx].lookups = HeapAlloc(GetProcessHeap(),0,sizeof(WORD) * language->features[idx].lookup_count); - for (j = 0; j < language->features[idx].lookup_count; j++) - language->features[idx].lookups[j] = GET_BE_WORD(feature->LookupListIndex[j]); - language->features[idx].tableType = FEATURE_GPOS_TABLE; + loaded_feature = &language->features[idx]; + loaded_feature->tag = MS_MAKE_TAG(feature_list->FeatureRecord[index].FeatureTag[0], + feature_list->FeatureRecord[index].FeatureTag[1], + feature_list->FeatureRecord[index].FeatureTag[2], + feature_list->FeatureRecord[index].FeatureTag[3]); + loaded_feature->feature = ((const BYTE *)feature_list + + GET_BE_WORD(feature_list->FeatureRecord[index].Feature)); + feature = loaded_feature->feature; + loaded_feature->lookup_count = GET_BE_WORD(feature->LookupCount); + loaded_feature->lookups = heap_alloc(loaded_feature->lookup_count * sizeof(*loaded_feature->lookups)); + for (j = 0; j < loaded_feature->lookup_count; ++j) + loaded_feature->lookups[j] = GET_BE_WORD(feature->LookupListIndex[j]); + loaded_feature->tableType = FEATURE_GPOS_TABLE; } language->feature_count += count; } diff --git a/dlls/usp10/shape.c b/dlls/usp10/shape.c index 9d07e5b002e..fff3304df41 100644 --- a/dlls/usp10/shape.c +++ b/dlls/usp10/shape.c @@ -660,7 +660,7 @@ static VOID *load_gsub_table(HDC hdc) int length = GetFontData(hdc, MS_MAKE_TAG('G', 'S', 'U', 'B'), 0, NULL, 0); if (length != GDI_ERROR) { - GSUB_Table = HeapAlloc(GetProcessHeap(),0,length); + GSUB_Table = heap_alloc(length); GetFontData(hdc, MS_MAKE_TAG('G', 'S', 'U', 'B'), 0, GSUB_Table, length); TRACE("Loaded GSUB table of %i bytes\n",length); } @@ -673,7 +673,7 @@ static VOID *load_gpos_table(HDC hdc) int length = GetFontData(hdc, MS_MAKE_TAG('G', 'P', 'O', 'S'), 0, NULL, 0); if (length != GDI_ERROR) { - GPOS_Table = HeapAlloc(GetProcessHeap(),0,length); + GPOS_Table = heap_alloc(length); GetFontData(hdc, MS_MAKE_TAG('G', 'P', 'O', 'S'), 0, GPOS_Table, length); TRACE("Loaded GPOS table of %i bytes\n",length); } @@ -686,7 +686,7 @@ static VOID *load_gdef_table(HDC hdc) int length = GetFontData(hdc, MS_MAKE_TAG('G', 'D', 'E', 'F'), 0, NULL, 0); if (length != GDI_ERROR) { - GDEF_Table = HeapAlloc(GetProcessHeap(),0,length); + GDEF_Table = heap_alloc(length); GetFontData(hdc, MS_MAKE_TAG('G', 'D', 'E', 'F'), 0, GDEF_Table, length); TRACE("Loaded GDEF table of %i bytes\n",length); } @@ -709,7 +709,7 @@ INT SHAPE_does_GSUB_feature_apply_to_chars(HDC hdc, SCRIPT_ANALYSIS *psa, Script INT glyph_count = count; INT rc; - glyphs = HeapAlloc(GetProcessHeap(),0,sizeof(WORD)*(count*2)); + glyphs = heap_alloc(2 * count * sizeof(*glyphs)); GetGlyphIndicesW(hdc, chars, count, glyphs, 0); rc = apply_GSUB_feature_to_glyph(hdc, psa, psc, glyphs, 0, write_dir, &glyph_count, feature); if (rc > GSUB_E_NOGLYPH) @@ -898,7 +898,7 @@ static void mark_invalid_combinations(HDC hdc, const WCHAR* pwcChars, INT cChars WCHAR invalid = 0x25cc; WORD invalid_glyph; - context_type = HeapAlloc(GetProcessHeap(),0,cChars); + context_type = heap_alloc(cChars); /* Mark invalid combinations */ for (i = 0; i < cChars; i++) @@ -1068,8 +1068,8 @@ static void ContextualShape_Arabic(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *p load_ot_tables(hdc, psc); - context_type = HeapAlloc(GetProcessHeap(),0,cChars); - context_shape = HeapAlloc(GetProcessHeap(),0,sizeof(INT) * cChars); + context_type = heap_alloc(cChars); + context_shape = heap_alloc(cChars * sizeof(*context_shape)); for (i = 0; i < cChars; i++) context_type[i] = get_table_entry( wine_shaping_table, pwcChars[i] ); @@ -1325,8 +1325,8 @@ static void ContextualShape_Syriac(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *p if (!psc->GSUB_Table) return; - context_type = HeapAlloc(GetProcessHeap(),0,cChars); - context_shape = HeapAlloc(GetProcessHeap(),0,sizeof(INT) * cChars); + context_type = heap_alloc(cChars); + context_shape = heap_alloc(cChars * sizeof(*context_shape)); for (i = 0; i < cChars; i++) context_type[i] = get_table_entry( wine_shaping_table, pwcChars[i] ); @@ -1487,7 +1487,7 @@ static void ContextualShape_Phags_pa(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS if (!psc->GSUB_Table) return; - context_shape = HeapAlloc(GetProcessHeap(),0,sizeof(INT) * cChars); + context_shape = heap_alloc(cChars * sizeof(*context_shape)); for (i = 0; i < cChars; i++) { @@ -2275,7 +2275,7 @@ static void ContextualShape_Sinhala(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS * return; } - input = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR) * (cChars * 3)); + input = heap_alloc(3 * cChars * sizeof(*input)); memcpy(input, pwcChars, cChars * sizeof(WCHAR)); @@ -2342,7 +2342,7 @@ static void ContextualShape_Devanagari(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSI return; } - input = HeapAlloc(GetProcessHeap(), 0, cChars * sizeof(WCHAR)); + input = heap_alloc(cChars * sizeof(*input)); memcpy(input, pwcChars, cChars * sizeof(WCHAR)); /* Step 1: Compose Consonant and Nukta */ @@ -2398,7 +2398,7 @@ static void ContextualShape_Bengali(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS * return; } - input = HeapAlloc(GetProcessHeap(), 0, (cChars * 2) * sizeof(WCHAR)); + input = heap_alloc(2 * cChars * sizeof(*input)); memcpy(input, pwcChars, cChars * sizeof(WCHAR)); /* Step 1: Decompose Vowels and Compose Consonants */ @@ -2462,7 +2462,7 @@ static void ContextualShape_Gurmukhi(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS return; } - input = HeapAlloc(GetProcessHeap(), 0, cChars * sizeof(WCHAR)); + input = heap_alloc(cChars * sizeof(*input)); memcpy(input, pwcChars, cChars * sizeof(WCHAR)); /* Step 1: Compose Consonants */ @@ -2506,7 +2506,7 @@ static void ContextualShape_Gujarati(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS return; } - input = HeapAlloc(GetProcessHeap(), 0, cChars * sizeof(WCHAR)); + input = heap_alloc(cChars * sizeof(*input)); memcpy(input, pwcChars, cChars * sizeof(WCHAR)); /* Step 1: Reorder within Syllables */ @@ -2557,7 +2557,7 @@ static void ContextualShape_Oriya(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *ps return; } - input = HeapAlloc(GetProcessHeap(), 0, (cChars*2) * sizeof(WCHAR)); + input = heap_alloc(2 * cChars * sizeof(*input)); memcpy(input, pwcChars, cChars * sizeof(WCHAR)); /* Step 1: Decompose Vowels and Compose Consonants */ @@ -2607,7 +2607,7 @@ static void ContextualShape_Tamil(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *ps return; } - input = HeapAlloc(GetProcessHeap(), 0, (cChars*2) * sizeof(WCHAR)); + input = heap_alloc(2 * cChars * sizeof(*input)); memcpy(input, pwcChars, cChars * sizeof(WCHAR)); /* Step 1: Decompose Vowels and Compose Consonants */ @@ -2657,7 +2657,7 @@ static void ContextualShape_Telugu(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *p return; } - input = HeapAlloc(GetProcessHeap(), 0, (cChars*2) * sizeof(WCHAR)); + input = heap_alloc(2 * cChars * sizeof(*input)); memcpy(input, pwcChars, cChars * sizeof(WCHAR)); /* Step 1: Decompose Vowels */ @@ -2709,7 +2709,7 @@ static void ContextualShape_Kannada(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS * return; } - input = HeapAlloc(GetProcessHeap(), 0, (cChars*3) * sizeof(WCHAR)); + input = heap_alloc(3 * cChars * sizeof(*input)); memcpy(input, pwcChars, cChars * sizeof(WCHAR)); /* Step 1: Decompose Vowels */ @@ -2754,7 +2754,7 @@ static void ContextualShape_Malayalam(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS return; } - input = HeapAlloc(GetProcessHeap(), 0, (cChars*2) * sizeof(WCHAR)); + input = heap_alloc(2 * cChars * sizeof(*input)); memcpy(input, pwcChars, cChars * sizeof(WCHAR)); /* Step 1: Decompose Vowels */ @@ -2792,7 +2792,7 @@ static void ContextualShape_Khmer(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *ps return; } - input = HeapAlloc(GetProcessHeap(), 0, cChars * sizeof(WCHAR)); + input = heap_alloc(cChars * sizeof(*input)); memcpy(input, pwcChars, cChars * sizeof(WCHAR)); /* Step 1: Reorder within Syllables */ @@ -2835,7 +2835,7 @@ static void ContextualShape_Mongolian(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS if (!psc->GSUB_Table) return; - context_shape = HeapAlloc(GetProcessHeap(),0,sizeof(INT) * cChars); + context_shape = heap_alloc(cChars * sizeof(*context_shape)); for (i = 0; i < cChars; i++) { @@ -2949,7 +2949,7 @@ static void ShapeCharGlyphProp_Arabic( HDC hdc, ScriptCache *psc, SCRIPT_ANALYSI INT dirR, dirL; BYTE *spaces; - spaces = HeapAlloc(GetProcessHeap(),0,cGlyphs); + spaces = heap_alloc(cGlyphs); memset(spaces,0,cGlyphs); if (psa->fLogicalOrder && psa->fRTL)