+respected proper function calling types cdecl/stdcall/fastcall
[captive.git] / src / libcaptive / mm / pool.c
1 /* $Id$
2  * reactos memory pools emulation of libcaptive
3  * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #include "config.h"
21
22 #include "captive/mm.h" /* self */
23 #include "reactos/internal/mm.h"        /* self */
24 #include "reactos/ntos/types.h" /* for PVOID etc. */
25 #include <glib/gmessages.h>
26 #include <glib/gmem.h>
27
28
29 /**
30  * ExAllocatePoolWithTag:
31  * @PoolType: Type of memory to allocate. Safely ignored by libcaptive as it is
32  * too low level for it.
33  * @NumberOfBytes: Size of the requested allocation. Value 0 permitted (returns %NULL).
34  * @Tag: 4-bytes of block identification for debugging purposes.
35  * Ignored by libcaptive.
36  *
37  * Allocates the specified memory block. libcaptive passes the allocation to
38  * g_malloc(). @Tag is no longer trackable for the allocated memory block.
39  * @Tag is ignored by libcaptive.
40  *
41  * Returns: Memory block base if successfuly allocated. %NULL otherwise.
42  * The allocated memory block is not cleared.
43  */
44 PVOID ExAllocatePoolWithTag(ULONG PoolType,ULONG NumberOfBytes,ULONG Tag)
45 {
46         if (!NumberOfBytes)
47                 return NULL;
48
49         return g_malloc(NumberOfBytes);
50 }
51
52 /**
53  * ExAllocatePool:
54  * @PoolType: Type of memory to allocate. Safely ignored by libcaptive as it is
55  * too low level for it.
56  * @NumberOfBytes: Size of the requested allocation. Value 0 permitted (returns %NULL).
57  *
58  * Allocates the specified memory block. Calls ExAllocatePoolWithTag() with
59  * undeterministic @Tag value.
60  *
61  * Returns: Memory block base if successfuly allocated. %NULL otherwise.
62  * The allocated memory block is not cleared.
63  */
64 PVOID ExAllocatePool(POOL_TYPE PoolType,ULONG NumberOfBytes)
65 {
66         return ExAllocatePoolWithTag(PoolType,NumberOfBytes,
67                         0);     /* Tag; reactos uses TAG_NONE ('None') but it is not documented for W32 */
68 }
69
70 /**
71  * ExFreePool:
72  * @Block: Base address of the memory block. %NULL value is forbidden.
73  *
74  * Deallocate the given memory block. Block must be already successfuly
75  * allocated by a previous ExAllocatePool() or ExAllocatePoolWithTag() call.
76  * You can no longer assume anything about this base address / memory block.
77  */
78 VOID ExFreePool(IN PVOID Block)
79 {
80         g_return_if_fail(Block!=NULL);
81
82         g_free(Block);
83 }