1995-03-19 18:39:39 +01:00
|
|
|
/*
|
|
|
|
* Local heap functions
|
|
|
|
*
|
|
|
|
* Copyright 1995 Alexandre Julliard
|
1996-05-06 18:06:24 +02:00
|
|
|
* Copyright 1996 Huw Davies
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* 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
|
1995-03-19 18:39:39 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note:
|
|
|
|
* All local heap functions need the current DS as first parameter
|
|
|
|
* when called from the emulation library, so they take one more
|
|
|
|
* parameter than usual.
|
|
|
|
*/
|
|
|
|
|
2001-01-02 21:13:02 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1995-03-19 18:39:39 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2003-08-26 04:29:48 +02:00
|
|
|
#include "winbase.h"
|
1995-03-19 18:39:39 +01:00
|
|
|
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* LocalAlloc (KERNEL32.@)
|
1998-03-29 21:44:57 +02:00
|
|
|
* RETURNS
|
|
|
|
* Handle: Success
|
|
|
|
* NULL: Failure
|
1996-05-06 18:06:24 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HLOCAL WINAPI LocalAlloc(
|
|
|
|
UINT flags, /* [in] Allocation attributes */
|
2002-09-21 03:21:00 +02:00
|
|
|
SIZE_T size /* [in] Number of bytes to allocate */
|
1998-03-29 21:44:57 +02:00
|
|
|
) {
|
1999-02-26 12:11:13 +01:00
|
|
|
return (HLOCAL)GlobalAlloc( flags, size );
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* LocalCompact (KERNEL32.@)
|
1996-05-06 18:06:24 +02:00
|
|
|
*/
|
2002-09-21 03:21:00 +02:00
|
|
|
SIZE_T WINAPI LocalCompact( UINT minfree )
|
1996-05-06 18:06:24 +02:00
|
|
|
{
|
|
|
|
return 0; /* LocalCompact does nothing in Win32 */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* LocalFlags (KERNEL32.@)
|
1998-03-29 21:44:57 +02:00
|
|
|
* RETURNS
|
|
|
|
* Value specifying allocation flags and lock count.
|
|
|
|
* LMEM_INVALID_HANDLE: Failure
|
1996-05-06 18:06:24 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT WINAPI LocalFlags(
|
|
|
|
HLOCAL handle /* [in] Handle of memory object */
|
1998-03-29 21:44:57 +02:00
|
|
|
) {
|
1999-02-26 12:11:13 +01:00
|
|
|
return GlobalFlags( (HGLOBAL)handle );
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* LocalFree (KERNEL32.@)
|
1998-03-29 21:44:57 +02:00
|
|
|
* RETURNS
|
|
|
|
* NULL: Success
|
|
|
|
* Handle: Failure
|
1996-05-06 18:06:24 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HLOCAL WINAPI LocalFree(
|
|
|
|
HLOCAL handle /* [in] Handle of memory object */
|
1998-03-29 21:44:57 +02:00
|
|
|
) {
|
1999-02-26 12:11:13 +01:00
|
|
|
return (HLOCAL)GlobalFree( (HGLOBAL)handle );
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* LocalHandle (KERNEL32.@)
|
1998-03-29 21:44:57 +02:00
|
|
|
* RETURNS
|
|
|
|
* Handle: Success
|
|
|
|
* NULL: Failure
|
1996-05-06 18:06:24 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HLOCAL WINAPI LocalHandle(
|
1998-03-29 21:44:57 +02:00
|
|
|
LPCVOID ptr /* [in] Address of local memory object */
|
|
|
|
) {
|
1999-02-26 12:11:13 +01:00
|
|
|
return (HLOCAL)GlobalHandle( ptr );
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* LocalLock (KERNEL32.@)
|
1998-03-29 21:44:57 +02:00
|
|
|
* Locks a local memory object and returns pointer to the first byte
|
|
|
|
* of the memory block.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Pointer: Success
|
|
|
|
* NULL: Failure
|
1996-05-06 18:06:24 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
LPVOID WINAPI LocalLock(
|
|
|
|
HLOCAL handle /* [in] Address of local memory object */
|
1998-03-29 21:44:57 +02:00
|
|
|
) {
|
1999-02-26 12:11:13 +01:00
|
|
|
return GlobalLock( (HGLOBAL)handle );
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* LocalReAlloc (KERNEL32.@)
|
1998-03-29 21:44:57 +02:00
|
|
|
* RETURNS
|
|
|
|
* Handle: Success
|
|
|
|
* NULL: Failure
|
1996-05-06 18:06:24 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HLOCAL WINAPI LocalReAlloc(
|
|
|
|
HLOCAL handle, /* [in] Handle of memory object */
|
2002-09-21 03:21:00 +02:00
|
|
|
SIZE_T size, /* [in] New size of block */
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT flags /* [in] How to reallocate object */
|
1998-03-29 21:44:57 +02:00
|
|
|
) {
|
1999-02-26 12:11:13 +01:00
|
|
|
return (HLOCAL)GlobalReAlloc( (HGLOBAL)handle, size, flags );
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* LocalShrink (KERNEL32.@)
|
1996-05-06 18:06:24 +02:00
|
|
|
*/
|
2002-09-21 03:21:00 +02:00
|
|
|
SIZE_T WINAPI LocalShrink( HGLOBAL handle, UINT newsize )
|
1996-05-06 18:06:24 +02:00
|
|
|
{
|
|
|
|
return 0; /* LocalShrink does nothing in Win32 */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* LocalSize (KERNEL32.@)
|
1998-03-29 21:44:57 +02:00
|
|
|
* RETURNS
|
|
|
|
* Size: Success
|
|
|
|
* 0: Failure
|
1996-05-06 18:06:24 +02:00
|
|
|
*/
|
2002-09-21 03:21:00 +02:00
|
|
|
SIZE_T WINAPI LocalSize(
|
1999-02-26 12:11:13 +01:00
|
|
|
HLOCAL handle /* [in] Handle of memory object */
|
1998-03-29 21:44:57 +02:00
|
|
|
) {
|
1999-02-26 12:11:13 +01:00
|
|
|
return GlobalSize( (HGLOBAL)handle );
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* LocalUnlock (KERNEL32.@)
|
1998-03-29 21:44:57 +02:00
|
|
|
* RETURNS
|
|
|
|
* TRUE: Object is still locked
|
|
|
|
* FALSE: Object is unlocked
|
1996-05-06 18:06:24 +02:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI LocalUnlock(
|
|
|
|
HLOCAL handle /* [in] Handle of memory object */
|
1998-03-29 21:44:57 +02:00
|
|
|
) {
|
1999-02-26 12:11:13 +01:00
|
|
|
return GlobalUnlock( (HGLOBAL)handle );
|
1996-05-06 18:06:24 +02:00
|
|
|
}
|