Changeset 3573 for trunk/kStuff/kHlp/Bare/kHlpBareHeap.c
- Timestamp:
- Aug 31, 2007, 6:09:23 AM (18 years ago)
- Location:
- trunk/kStuff/kHlp/Bare
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/kHlp/Bare/kHlpBareHeap.c
r3570 r3573 1 1 /* $Id$ */ 2 2 /** @file 3 * 4 * kLdr - The Dynamic Loader, Helper Functions, Heap.5 * 6 * Copyright (c) 2006 knut st. osmundsen <bird-kbuild-src@anduin.net> 7 * 8 * 9 * This file is part of k Ldr.10 * 11 * k Ldr is free software; you can redistribute it and/or modify12 * it under the terms of the GNU General Public License as published by13 * the Free Software Foundation; either version 2 of the License, or14 * (at your option) any later version.15 * 16 * k Ldris distributed in the hope that it will be useful,3 * kHlpBare - Heap. 4 */ 5 6 /* 7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net> 8 * 9 * This file is part of kStuff. 10 * 11 * kStuff is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * kStuff is distributed in the hope that it will be useful, 17 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNUGeneral Public License for more details.20 * 21 * You should have received a copy of the GNU General Public License22 * along with kLdr; if not, write to the Free Software23 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with kStuff; if not, write to the Free Software 23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 24 * 25 25 */ … … 30 30 * Header Files * 31 31 *******************************************************************************/ 32 #ifdef __OS2__ 32 #include <k/kHlpAlloc.h> 33 34 #if K_OS == K_OS_OS2 33 35 # define INCL_BASE 34 36 # define INCL_ERRORS 35 37 # include <os2.h> 36 #elif defined(__WIN__)38 #elif K_OS == K_OS_WINDOWS 37 39 # include <Windows.h> 38 40 #else 39 41 # error "port me" 40 42 #endif 41 42 #include <k/kLdr.h>43 #include "kLdrHlp.h"44 45 43 46 44 … … 87 85 * Assert that a heap free block is valid. */ 88 86 #ifdef KLDRHEAP_STRICT 89 # define KLDRHEAP_ASSERT(expr) k ldrHlpAssert(expr)87 # define KLDRHEAP_ASSERT(expr) kHlpAssert(expr) 90 88 91 89 # define KLDRHEAP_ASSERT_BLOCK(pHeap, pBlock) \ … … 193 191 * @returns 0 on success, non-zero OS specific status code on failure. 194 192 */ 195 int kldrHlpHeapInit(void)193 KHLP_DECL(int) kHlpHeapInit(void) 196 194 { 197 195 return kLdrHeapInit(&g_Heap); … … 202 200 * Terminates the kLdr heap. 203 201 */ 204 void kldrHlpHeapTerm(void)202 KHLP_DECL(void) kHlpHeapTerm(void) 205 203 { 206 204 kLdrHeapDelete(&g_Heap); … … 214 212 * @param cb The requested heap block size. 215 213 */ 216 void *kldrHlpAlloc(KSIZE cb)214 KHLP_DECL(void *) kHlpAlloc(KSIZE cb) 217 215 { 218 216 return kLdrHeapAlloc(&g_Heap, cb); … … 226 224 * @param cb The requested heap block size. 227 225 */ 228 void *kldrHlpAllocZ(KSIZE cb)226 KHLP_DECL(void *) kHlpAllocZ(KSIZE cb) 229 227 { 230 228 void *pv = kLdrHeapAlloc(&g_Heap, cb); 231 229 if (pv) 232 k LdrHlpMemSet(pv, 0, cb);230 kHlpMemSet(pv, 0, cb); 233 231 return pv; 234 232 } … … 238 236 * Frees memory allocated off the kLdr heap. 239 237 * 240 * @param pv Pointer to the heap block returned by k ldrHlpAlloc().241 */ 242 void kldrHlpFree(void *pv)238 * @param pv Pointer to the heap block returned by kHlpAlloc(). 239 */ 240 KHLP_DECL(void) kHlpFree(void *pv) 243 241 { 244 242 kLdrHeapFree(&g_Heap, pv); … … 252 250 * @param cb The amount of memory. 253 251 */ 254 void kldrHlpHeapDonate(void *pv, KSIZE cb)252 KHLP_DECL(void) kHlpHeapDonate(void *pv, KSIZE cb) 255 253 { 256 254 kLdrHeapDonate(&g_Heap, pv, cb); … … 652 650 static int kLdrHeapSegAlloc(PKLDRHEAPSEG pSeg, KSIZE cbMin) 653 651 { 654 #if def __OS2__652 #if K_OS == K_OS_OS2 655 653 APIRET rc; 656 654 … … 667 665 } 668 666 669 #elif defined(__WIN__)667 #elif K_OS == K_OS_WINDOWS 670 668 pSeg->cb = (cbMin + 0xffff) & ~(KSIZE)0xffff; 671 669 pSeg->pvBase = VirtualAlloc(NULL, pSeg->cb, MEM_COMMIT, PAGE_READWRITE); … … 691 689 static void kLdrHeapSegFree(PKLDRHEAPSEG pSeg) 692 690 { 693 #if def __OS2__691 #if K_OS == K_OS_OS2 694 692 APIRET rc = DosFreeMem(pSeg->pvBase); 695 693 KLDRHEAP_ASSERT(!rc); (void)rc; 696 694 697 #elif defined(__WIN__)695 #elif K_OS == K_OS_WINDOWS 698 696 BOOL fRc = VirtualFree(pSeg->pvBase, 0 /*pSeg->cb*/, MEM_RELEASE); 699 697 KLDRHEAP_ASSERT(fRc); (void)fRc;
Note:
See TracChangeset
for help on using the changeset viewer.