Sweden-Number/memory/heap.c

102 lines
2.6 KiB
C

/*
* Win32 heap functions
*
* Copyright 1996 Alexandre Julliard
* Copyright 1998 Ulrich Weigand
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <assert.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winnt.h"
#include "winreg.h"
#include "winternl.h"
#include "wine/unicode.h"
#include "thread.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(heap);
/***********************************************************************
* HeapLock (KERNEL32.@)
* Attempts to acquire the critical section object for a specified heap.
*
* RETURNS
* TRUE: Success
* FALSE: Failure
*/
BOOL WINAPI HeapLock(
HANDLE heap /* [in] Handle of heap to lock for exclusive access */
) {
return RtlLockHeap( heap );
}
/***********************************************************************
* HeapUnlock (KERNEL32.@)
* Releases ownership of the critical section object.
*
* RETURNS
* TRUE: Success
* FALSE: Failure
*/
BOOL WINAPI HeapUnlock(
HANDLE heap /* [in] Handle to the heap to unlock */
) {
return RtlUnlockHeap( heap );
}
/***********************************************************************
* GetProcessHeap (KERNEL32.@)
*/
HANDLE WINAPI GetProcessHeap(void)
{
return NtCurrentTeb()->Peb->ProcessHeap;
}
/* FIXME: these functions are needed for dlls that aren't properly separated yet */
LPVOID WINAPI HeapAlloc( HANDLE heap, DWORD flags, SIZE_T size )
{
return RtlAllocateHeap( heap, flags, size );
}
BOOL WINAPI HeapFree( HANDLE heap, DWORD flags, LPVOID ptr )
{
return RtlFreeHeap( heap, flags, ptr );
}
LPVOID WINAPI HeapReAlloc( HANDLE heap, DWORD flags, LPVOID ptr, SIZE_T size )
{
return RtlReAllocateHeap( heap, flags, ptr, size );
}
SIZE_T WINAPI HeapSize( HANDLE heap, DWORD flags, LPVOID ptr )
{
return RtlSizeHeap( heap, flags, ptr );
}