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

Last change on this file since 7029 was 6954, checked in by sandervl, 24 years ago

reduce heap overhead + always allocate from high memory

File size: 1.5 KB
Line 
1/* $Id: os2heap.h,v 1.8 2001-10-06 18:53:11 sandervl 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 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, totalAlloc, nrHeaps;
54 HANDLE hPrimaryHeap;
55 BOOL fInitialized;
56 HEAPELEM *heapelem;
57
58 char *pInitialHeapMem;
59 Heap_t uheap;
60
61 OS2Heap *next;
62 static OS2Heap *heap;
63};
64
65#endif
Note: See TracBrowser for help on using the repository browser.