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

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

heap updates/fixes

File size: 1.6 KB
Line 
1/* $Id: os2heap.h,v 1.5 2001-07-06 13:47:19 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
19#define MAGIC_NR_HEAP 0x87654321
20//must be a multiple of 8 bytes (alignment)
21typedef struct _tagHEAPELEM {
22 DWORD magic; //magic number
23 LPVOID lpMem; //pointer returned by malloc
24 struct _tagHEAPELEM *prev;
25 struct _tagHEAPELEM *next;
26} HEAPELEM;
27
28//extra overhead needed for quake 2 or 3 (a long time ago...)
29//#define HEAP_OVERHEAD (sizeof(HEAPELEM)+60)
30//+8 to make sure we can align the pointer at 8 byte boundary
31#define HEAP_OVERHEAD (sizeof(HEAPELEM)+8)
32
33#define GET_HEAPOBJ(ptr) (HEAPELEM *)((char *)ptr - sizeof(HEAPELEM));
34
35class OS2Heap
36{
37public:
38 OS2Heap(HANDLE hHeap, DWORD flOptions, DWORD dwInitialSize, DWORD dwMaximumSize);
39 ~OS2Heap();
40
41 HANDLE getHeapHandle() { return(hPrimaryHeap); };
42
43 LPVOID Alloc(DWORD dwFlags, DWORD dwBytes);
44 LPVOID ReAlloc(DWORD dwFlags, LPVOID lpMem, DWORD dwBytes);
45 BOOL Free(DWORD dwFlags, LPVOID lpMem);
46 DWORD Size(DWORD dwFlags, PVOID lpMem);
47 DWORD Compact(DWORD dwFlags);
48 BOOL Validate(DWORD dwFlags, LPCVOID lpMem);
49 BOOL Walk(void *lpEntry);
50
51 static OS2Heap *find(HANDLE hHeap);
52
53private:
54protected:
55
56 VMutex *hmutex;
57
58 DWORD dwMaximumSize, dwInitialSize, flOptions, totalAlloc, nrHeaps;
59 HANDLE hPrimaryHeap;
60 BOOL fInitialized;
61 HEAPELEM *heapelem;
62
63 OS2Heap *next;
64 static OS2Heap *heap;
65};
66
67#endif
Note: See TracBrowser for help on using the repository browser.