source: trunk/src/kernel32/os2heap.h@ 7360

Last change on this file since 7360 was 7360, checked in by phaller, 24 years ago

slightly more tuning

File size: 1.5 KB
Line 
1/* $Id: os2heap.h,v 1.10 2001-11-16 14:52:56 phaller Exp $ */
2
3/*
4 *
5 * Project Odin Software License can be found in LICENSE.TXT
6 *
7 */
8/*
9 * Heap class for OS/2
10 *
11 * Copyright 1998 Sander van Leeuwen
12 *
13 */
14#ifndef __OS2HEAP_H__
15#define __OS2HEAP_H__
16
17#include "vmutex.h"
18#include <umalloc.h>
19
20#define MAGIC_NR_HEAP 0x87654321
21//must be a multiple of 8 bytes (alignment)
22typedef struct _tagHEAPELEM {
23 DWORD magic; //magic number
24 LPVOID lpMem; //pointer returned by malloc
25} HEAPELEM;
26
27//+8 to make sure we can align the pointer at 8 byte boundary
28#define HEAP_OVERHEAD (sizeof(HEAPELEM)+8)
29
30#define GET_HEAPOBJ(ptr) (HEAPELEM *)((char *)ptr - sizeof(HEAPELEM));
31
32class OS2Heap
33{
34public:
35 OS2Heap(DWORD flOptions, DWORD dwInitialSize, DWORD dwMaximumSize);
36 ~OS2Heap();
37
38 HANDLE INLINE getHeapHandle() { return(hPrimaryHeap); };
39
40 LPVOID Alloc(DWORD dwFlags, DWORD dwBytes);
41 LPVOID ReAlloc(DWORD dwFlags, LPVOID lpMem, DWORD dwBytes);
42 BOOL Free(DWORD dwFlags, LPVOID lpMem);
43 DWORD Size(DWORD dwFlags, PVOID lpMem);
44 DWORD Compact(DWORD dwFlags);
45 BOOL Validate(DWORD dwFlags, LPCVOID lpMem);
46 BOOL Walk(void *lpEntry);
47
48 static OS2Heap *find(HANDLE hHeap);
49
50private:
51protected:
52
53 DWORD dwMaximumSize, dwInitialSize, flOptions, nrHeaps;
54#ifdef DEBUG
55 DWORD totalAlloc;
56#endif
57 HANDLE hPrimaryHeap;
58 BOOL fInitialized;
59 HEAPELEM *heapelem;
60
61 char *pInitialHeapMem;
62 Heap_t uheap;
63
64 OS2Heap *next;
65 static OS2Heap *heap;
66};
67
68#endif
Note: See TracBrowser for help on using the repository browser.