Commit b6ee614a authored by Oleg Prokhorov's avatar Oleg Prokhorov Committed by Alexandre Julliard

Another portion of HeapReAlloc fixes.

parent 6661f304
...@@ -159,10 +159,17 @@ static void *grow_array( void *array, unsigned int *count, size_t elem ) ...@@ -159,10 +159,17 @@ static void *grow_array( void *array, unsigned int *count, size_t elem )
void *new_array; void *new_array;
unsigned int new_count = *count + *count / 2; unsigned int new_count = *count + *count / 2;
if (new_count < 32) new_count = 32; if (new_count < 32) new_count = 32;
if ((new_array = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, array, new_count * elem )))
if (array)
new_array = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, array, new_count * elem );
else
new_array = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, new_count * elem );
if (new_array)
*count = new_count; *count = new_count;
else else
HeapFree( GetProcessHeap(), 0, array ); if (array)
HeapFree( GetProcessHeap(), 0, array );
return new_array; return new_array;
} }
......
...@@ -124,7 +124,12 @@ VHSTR WINAPI vsmStringAdd16(LPCSTR lpszName) ...@@ -124,7 +124,12 @@ VHSTR WINAPI vsmStringAdd16(LPCSTR lpszName)
{ {
index = vhstr_alloc; index = vhstr_alloc;
vhstr_alloc += 20; vhstr_alloc += 20;
vhstrlist = HeapReAlloc(heap, HEAP_ZERO_MEMORY, vhstrlist,
if (vhstrlist)
vhstrlist = HeapReAlloc(heap, HEAP_ZERO_MEMORY, vhstrlist,
sizeof(VHSTR_STRUCT *) * vhstr_alloc);
else
vhstrlist = HeapAlloc(heap, HEAP_ZERO_MEMORY,
sizeof(VHSTR_STRUCT *) * vhstr_alloc); sizeof(VHSTR_STRUCT *) * vhstr_alloc);
} }
if (index == 0xffff) if (index == 0xffff)
...@@ -229,7 +234,11 @@ RETERR16 VCP_VirtnodeCreate(LPVCPFILESPEC vfsSrc, LPVCPFILESPEC vfsDst, WORD fl, ...@@ -229,7 +234,11 @@ RETERR16 VCP_VirtnodeCreate(LPVCPFILESPEC vfsSrc, LPVCPFILESPEC vfsDst, WORD fl,
if (vn_last == vn_num) if (vn_last == vn_num)
{ {
vn_num += 20; vn_num += 20;
pvnlist = HeapReAlloc(heap, HEAP_ZERO_MEMORY, pvnlist, if (pvnlist)
pvnlist = HeapReAlloc(heap, HEAP_ZERO_MEMORY, pvnlist,
sizeof(LPVIRTNODE *) * vn_num);
else
pvnlist = HeapAlloc(heap, HEAP_ZERO_MEMORY,
sizeof(LPVIRTNODE *) * vn_num); sizeof(LPVIRTNODE *) * vn_num);
} }
pvnlist[vn_last] = HeapAlloc(heap, HEAP_ZERO_MEMORY, sizeof(VIRTNODE)); pvnlist[vn_last] = HeapAlloc(heap, HEAP_ZERO_MEMORY, sizeof(VIRTNODE));
......
...@@ -334,10 +334,17 @@ static int AllocEntry(void) ...@@ -334,10 +334,17 @@ static int AllocEntry(void)
} }
TRACE("Growing cache\n"); TRACE("Growing cache\n");
glyphsetCache = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
if (glyphsetCache)
glyphsetCache = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
glyphsetCache, glyphsetCache,
(glyphsetCacheSize + INIT_CACHE_SIZE) (glyphsetCacheSize + INIT_CACHE_SIZE)
* sizeof(*glyphsetCache)); * sizeof(*glyphsetCache));
else
glyphsetCache = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
(glyphsetCacheSize + INIT_CACHE_SIZE)
* sizeof(*glyphsetCache));
for(best = i = glyphsetCacheSize; i < glyphsetCacheSize + INIT_CACHE_SIZE; for(best = i = glyphsetCacheSize; i < glyphsetCacheSize + INIT_CACHE_SIZE;
i++) { i++) {
glyphsetCache[i].next = i + 1; glyphsetCache[i].next = i + 1;
...@@ -538,19 +545,37 @@ static BOOL UploadGlyph(X11DRV_PDEVICE *physDev, int glyph) ...@@ -538,19 +545,37 @@ static BOOL UploadGlyph(X11DRV_PDEVICE *physDev, int glyph)
if(entry->nrealized <= glyph) { if(entry->nrealized <= glyph) {
entry->nrealized = (glyph / 128 + 1) * 128; entry->nrealized = (glyph / 128 + 1) * 128;
entry->realized = HeapReAlloc(GetProcessHeap(),
if (entry->realized)
entry->realized = HeapReAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
entry->realized, entry->realized,
entry->nrealized * sizeof(BOOL)); entry->nrealized * sizeof(BOOL));
else
entry->realized = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
entry->nrealized * sizeof(BOOL));
if(entry->glyphset == 0) { if(entry->glyphset == 0) {
entry->bitmaps = HeapReAlloc(GetProcessHeap(), if (entry->bitmaps)
entry->bitmaps = HeapReAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
entry->bitmaps, entry->bitmaps,
entry->nrealized * sizeof(entry->bitmaps[0])); entry->nrealized * sizeof(entry->bitmaps[0]));
entry->gis = HeapReAlloc(GetProcessHeap(), else
entry->bitmaps = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
entry->nrealized * sizeof(entry->bitmaps[0]));
if (entry->gis)
entry->gis = HeapReAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
entry->gis, entry->gis,
entry->nrealized * sizeof(entry->gis[0])); entry->nrealized * sizeof(entry->gis[0]));
else
entry->gis = HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
entry->nrealized * sizeof(entry->gis[0]));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment