mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[msvcrt]
- Use the process heap for malloc and friends - Fixes a crash during GIMP startup (bug #3503, part 1) svn path=/trunk/; revision=44306
This commit is contained in:
parent
91523d7181
commit
b06cec2ffd
1 changed files with 8 additions and 10 deletions
|
@ -34,8 +34,6 @@
|
|||
/* round to 16 bytes + alloc at minimum 16 bytes */
|
||||
#define ROUND_SIZE(size) (max(16, ROUND_UP(size, 16)))
|
||||
|
||||
extern HANDLE hHeap;
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
@ -46,7 +44,7 @@ void* malloc(size_t _size)
|
|||
if (nSize<_size)
|
||||
return NULL;
|
||||
|
||||
return HeapAlloc(hHeap, 0, nSize);
|
||||
return HeapAlloc(GetProcessHeap(), 0, nSize);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -54,7 +52,7 @@ void* malloc(size_t _size)
|
|||
*/
|
||||
void free(void* _ptr)
|
||||
{
|
||||
HeapFree(hHeap,0,_ptr);
|
||||
HeapFree(GetProcessHeap(),0,_ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -68,7 +66,7 @@ void* calloc(size_t _nmemb, size_t _size)
|
|||
if ( (_nmemb > ((size_t)-1 / _size)) || (cSize<nSize))
|
||||
return NULL;
|
||||
|
||||
return HeapAlloc(hHeap, HEAP_ZERO_MEMORY, cSize );
|
||||
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cSize );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -93,7 +91,7 @@ void* realloc(void* _ptr, size_t _size)
|
|||
if (nSize<_size)
|
||||
return NULL;
|
||||
|
||||
return HeapReAlloc(hHeap, 0, _ptr, nSize);
|
||||
return HeapReAlloc(GetProcessHeap(), 0, _ptr, nSize);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -108,7 +106,7 @@ void* _expand(void* _ptr, size_t _size)
|
|||
if (nSize<_size)
|
||||
return NULL;
|
||||
|
||||
return HeapReAlloc(hHeap, HEAP_REALLOC_IN_PLACE_ONLY, _ptr, nSize);
|
||||
return HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, _ptr, nSize);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -116,7 +114,7 @@ void* _expand(void* _ptr, size_t _size)
|
|||
*/
|
||||
size_t _msize(void* _ptr)
|
||||
{
|
||||
return HeapSize(hHeap, 0, _ptr);
|
||||
return HeapSize(GetProcessHeap(), 0, _ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -124,7 +122,7 @@ size_t _msize(void* _ptr)
|
|||
*/
|
||||
int _heapchk(void)
|
||||
{
|
||||
if (!HeapValidate(hHeap, 0, NULL))
|
||||
if (!HeapValidate(GetProcessHeap(), 0, NULL))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -134,7 +132,7 @@ int _heapchk(void)
|
|||
*/
|
||||
int _heapmin(void)
|
||||
{
|
||||
if (!HeapCompact(hHeap, 0))
|
||||
if (!HeapCompact(GetProcessHeap(), 0))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue