From 3c5d760b6c61cfb446a9336ad3b66b4260ff9f81 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Fri, 21 Jan 2005 12:27:32 +0000 Subject: [PATCH] Implement MyFree, MyMalloc and MyReAlloc. svn path=/trunk/; revision=13182 --- reactos/lib/setupapi/Makefile.in | 1 + reactos/lib/setupapi/misc.c | 93 ++++++++++++++++++++++++++++++ reactos/lib/setupapi/setupapi.spec | 9 ++- 3 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 reactos/lib/setupapi/misc.c diff --git a/reactos/lib/setupapi/Makefile.in b/reactos/lib/setupapi/Makefile.in index 0732ffb5b09..0a02edaccb0 100644 --- a/reactos/lib/setupapi/Makefile.in +++ b/reactos/lib/setupapi/Makefile.in @@ -15,6 +15,7 @@ C_SRCS = \ dirid.c \ diskspace.c \ install.c \ + misc.c \ parser.c \ queue.c \ setupcab.c \ diff --git a/reactos/lib/setupapi/misc.c b/reactos/lib/setupapi/misc.c new file mode 100644 index 00000000000..619f80a417f --- /dev/null +++ b/reactos/lib/setupapi/misc.c @@ -0,0 +1,93 @@ +/* + * Setupapi miscellaneous functions + * + * Copyright 2005 Eric Kohl + * + * 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 + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "winreg.h" +#include "setupapi.h" + + +/************************************************************************** + * MyFree [SETUPAPI.@] + * + * Frees an allocated memory block from the process heap. + * + * PARAMS + * lpMem [I] pointer to memory block which will be freed + * + * RETURNS + * None + */ + +VOID WINAPI MyFree(LPVOID lpMem) +{ + HeapFree(GetProcessHeap(), 0, lpMem); +} + + +/************************************************************************** + * MyMalloc [SETUPAPI.@] + * + * Allocates memory block from the process heap. + * + * PARAMS + * dwSize [I] size of the allocated memory block + * + * RETURNS + * Success: pointer to allocated memory block + * Failure: NULL + */ + +LPVOID WINAPI MyMalloc(DWORD dwSize) +{ + return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize); +} + + +/************************************************************************** + * MyRealloc [SETUPAPI.@] + * + * Changes the size of an allocated memory block or allocates a memory + * block from the process heap. + * + * PARAMS + * lpSrc [I] pointer to memory block which will be resized + * dwSize [I] new size of the memory block + * + * RETURNS + * Success: pointer to the resized memory block + * Failure: NULL + * + * NOTES + * If lpSrc is a NULL-pointer, then MyRealloc allocates a memory + * block like MyMalloc. + */ + +LPVOID WINAPI MyRealloc(LPVOID lpSrc, DWORD dwSize) +{ + if (lpSrc == NULL) + return HeapAlloc(GetProcessHeap(), 0, dwSize); + + return HeapReAlloc(GetProcessHeap(), 0, lpSrc, dwSize); +} diff --git a/reactos/lib/setupapi/setupapi.spec b/reactos/lib/setupapi/setupapi.spec index 88e8ca4cd12..ace1a394cf6 100644 --- a/reactos/lib/setupapi/setupapi.spec +++ b/reactos/lib/setupapi/setupapi.spec @@ -1,3 +1,6 @@ +@ stub AddTagToGroupOrderListEntry +@ stub AppendStringToMultiSz +@ stub AssertFail @ stdcall CM_Connect_MachineW(wstr ptr) @ stdcall CM_Disconnect_Machine(long) @ stub CM_Free_Log_Conf_Handle @@ -36,10 +39,10 @@ @ stub MemoryInitialize @ stub MultiByteToUnicode @ stub MultiSzFromSearchControl -@ stub MyFree +@ stdcall MyFree(ptr) @ stub MyGetFileTitle -@ stub MyMalloc -@ stub MyRealloc +@ stdcall MyMalloc(long) +@ stdcall MyRealloc(ptr long) @ stub OpenAndMapFileForRead @ stub OutOfMemory @ stub QueryMultiSzValueToArray