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

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

heap changes/fixes

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