1 | /* $Id: kHlpAlloc.h 2 2007-11-16 16:07:14Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * kHlpAlloc - Memory Allocation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2006-2007 knut st. osmundsen <[email protected]>
|
---|
8 | *
|
---|
9 | * This file is part of kStuff.
|
---|
10 | *
|
---|
11 | * kStuff is free software; you can redistribute it and/or modify
|
---|
12 | * it under the terms of the GNU Lesser General Public License as published
|
---|
13 | * by the Free Software Foundation; either version 2 of the License, or
|
---|
14 | * (at your option) any later version.
|
---|
15 | *
|
---|
16 | * kStuff is distributed in the hope that it will be useful,
|
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | * GNU Lesser General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU Lesser General Public License
|
---|
22 | * along with kStuff; if not, write to the Free Software
|
---|
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
24 | *
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef ___k_kHlpAlloc_h___
|
---|
28 | #define ___k_kHlpAlloc_h___
|
---|
29 |
|
---|
30 | #include <k/kHlpDefs.h>
|
---|
31 | #include <k/kTypes.h>
|
---|
32 |
|
---|
33 | /** @defgroup grp_kHlpAlloc kHlpAlloc - Memory Allocation
|
---|
34 | * @addtogroup grp_kHlp
|
---|
35 | * @{*/
|
---|
36 |
|
---|
37 | /** @def kHlpAllocA
|
---|
38 | * The alloca() wrapper. */
|
---|
39 | #ifdef __GNUC__
|
---|
40 | # define kHlpAllocA(a) __builtin_alloca(a)
|
---|
41 | #elif defined(_MSC_VER)
|
---|
42 | # include <malloc.h>
|
---|
43 | # define kHlpAllocA(a) alloca(a)
|
---|
44 | #else
|
---|
45 | # error "Port Me."
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | #ifdef __cplusplus
|
---|
49 | extern "C" {
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | KHLP_DECL(void *) kHlpAlloc(KSIZE cb);
|
---|
53 | KHLP_DECL(void *) kHlpAllocZ(KSIZE cb);
|
---|
54 | KHLP_DECL(void *) kHlpDup(const void *pv, KSIZE cb);
|
---|
55 | KHLP_DECL(char *) kHlpStrDup(const char *psz);
|
---|
56 | KHLP_DECL(void *) kHlpRealloc(void *pv, KSIZE cb);
|
---|
57 | KHLP_DECL(void) kHlpFree(void *pv);
|
---|
58 |
|
---|
59 | KHLP_DECL(int) kHlpPageAlloc(void **ppv, KSIZE cb, KPROT enmProt, KBOOL fFixed);
|
---|
60 | KHLP_DECL(int) kHlpPageProtect(void *pv, KSIZE cb, KPROT enmProt);
|
---|
61 | KHLP_DECL(int) kHlpPageFree(void *pv, KSIZE cb);
|
---|
62 |
|
---|
63 | KHLP_DECL(int) kHlpHeapInit(void);
|
---|
64 | KHLP_DECL(void) kHlpHeapTerm(void);
|
---|
65 | KHLP_DECL(void) kHlpHeapDonate(void *pv, KSIZE cb);
|
---|
66 |
|
---|
67 | #ifdef __cplusplus
|
---|
68 | }
|
---|
69 | #endif
|
---|
70 |
|
---|
71 | /** @} */
|
---|
72 |
|
---|
73 | #endif
|
---|
74 |
|
---|