source: trunk/src/kernel32/os2heap.h

Last change on this file was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

File size: 1.7 KB
Line 
1/* $Id: os2heap.h,v 1.11 2002-01-06 16:48:47 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 DWORD cursize; //current size (HeapReAlloc changes this)
26 DWORD orgsize; //size used to allocate this memory block
27} HEAPELEM;
28
29#define HEAP_ALIGNMENT 8
30#define HEAP_ALIGNMENT_MASK (~7)
31
32#define HEAP_OVERHEAD (sizeof(HEAPELEM))
33
34#define HEAP_ALIGN(a) (((DWORD)a+HEAP_ALIGNMENT-1) & HEAP_ALIGNMENT_MASK)
35
36#define GET_HEAPOBJ(ptr) (HEAPELEM *)((char *)ptr - sizeof(HEAPELEM));
37
38class OS2Heap
39{
40public:
41 OS2Heap(DWORD flOptions, DWORD dwInitialSize, DWORD dwMaximumSize);
42 ~OS2Heap();
43
44 HANDLE getHeapHandle() { return(hPrimaryHeap); };
45
46 LPVOID Alloc(DWORD dwFlags, DWORD dwBytes);
47 LPVOID ReAlloc(DWORD dwFlags, LPVOID lpMem, DWORD dwBytes);
48 BOOL Free(DWORD dwFlags, LPVOID lpMem);
49 DWORD Size(DWORD dwFlags, PVOID lpMem);
50 DWORD Compact(DWORD dwFlags);
51 BOOL Validate(DWORD dwFlags, LPCVOID lpMem);
52 BOOL Walk(void *lpEntry);
53
54 static OS2Heap *find(HANDLE hHeap);
55
56private:
57protected:
58
59 DWORD dwMaximumSize, dwInitialSize, flOptions, nrHeaps;
60#ifdef DEBUG
61 DWORD totalAlloc;
62#endif
63 HANDLE hPrimaryHeap;
64 BOOL fInitialized;
65 HEAPELEM *heapelem;
66
67 char *pInitialHeapMem;
68 Heap_t uheap;
69
70 OS2Heap *next;
71 static OS2Heap *heap;
72};
73
74#endif
Note: See TracBrowser for help on using the repository browser.