mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:02:56 +00:00
Ntdll implements the user heaps. Don't try to handle this yourself.
svn path=/trunk/; revision=7847
This commit is contained in:
parent
c6651faa5f
commit
a27a41929d
1 changed files with 2 additions and 32 deletions
|
@ -1,31 +1,12 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <kernel32/heap.h>
|
|
||||||
#include <msvcrt/malloc.h>
|
#include <msvcrt/malloc.h>
|
||||||
#include <msvcrt/stdlib.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
void* _expand(void* pold, size_t size)
|
void* _expand(void* pold, size_t size)
|
||||||
{
|
{
|
||||||
PHEAP_BUCKET pbucket;
|
return HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, pold, size);
|
||||||
PHEAP_SUBALLOC psub;
|
|
||||||
PHEAP_FRAGMENT pfrag = (PHEAP_FRAGMENT)((LPVOID)pold-HEAP_FRAG_ADMIN_SIZE);
|
|
||||||
|
|
||||||
/* sanity checks */
|
|
||||||
if (pfrag->Magic != HEAP_FRAG_MAGIC)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* get bucket size */
|
|
||||||
psub = pfrag->Sub;
|
|
||||||
pbucket = psub->Bucket;
|
|
||||||
if(size <= pbucket->Size) {
|
|
||||||
pfrag->Size=size;
|
|
||||||
return pold;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -33,16 +14,5 @@ void* _expand(void* pold, size_t size)
|
||||||
*/
|
*/
|
||||||
size_t _msize(void* pBlock)
|
size_t _msize(void* pBlock)
|
||||||
{
|
{
|
||||||
PHEAP_BUCKET pbucket;
|
return HeapSize (GetProcessHeap(), 0, pBlock);
|
||||||
PHEAP_SUBALLOC psub;
|
|
||||||
PHEAP_FRAGMENT pfrag = (PHEAP_FRAGMENT)((LPVOID)pBlock-HEAP_FRAG_ADMIN_SIZE);
|
|
||||||
|
|
||||||
/* sanity checks */
|
|
||||||
if (pfrag->Magic != HEAP_FRAG_MAGIC)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* get bucket size */
|
|
||||||
psub = pfrag->Sub;
|
|
||||||
pbucket = psub->Bucket;
|
|
||||||
return pbucket->Size;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue