00001 /* 00002 * This file was written by Todd M. Austin, University of Wisconsin - Madison 00003 * Department of Computer Sciences 00004 * 00005 * Copyright (C) 1992, 1993, 1994, 1995 by Todd M. Austin 00006 * 00007 * This source file is distributed in the hope that it will be useful, 00008 * but without any warranty. No author or distributor accepts 00009 * responsibility to anyone for the consequences of using it or for 00010 * whether it serves any particular purpose or works at all. 00011 * 00012 * Everyone is granted permission to copy, modify and redistribute 00013 * this source file under the following conditions: 00014 * 00015 * Permission is granted to anyone to make or distribute copies 00016 * of this source code, either as received or modified, in any 00017 * medium, provided that all copyright notices, permission and 00018 * nonwarranty notices are preserved, and that the distributor 00019 * grants the recipient permission for further redistribution as 00020 * permitted by this document. 00021 * 00022 * Permission is granted to distribute this file in compiled 00023 * or executable form under the same conditions applying for 00024 * source code, provided that either 00025 * A. it is accompanied by the corresponding machine-readable 00026 * source code, or 00027 * B. it is accompanied by a written offer, with no time limit, 00028 * to give anyone a machine-readable copy of the corresponding 00029 * source code in return for reimbursement of the cost of 00030 * distribution. This written offer must permit verbatim 00031 * duplication by anyone. 00032 * C. it is distributed by someone who received only the 00033 * executable form, and is accompanied by a copy of the 00034 * written offer of source code which s/he received along with it. 00035 * 00036 * In other words, you are welcome to use, share and improve this 00037 * source file. You are forbidden to forbid anyone else to use, share 00038 * and improve what you give them. 00039 * 00040 * INTERNET: austin@cs.wisc.edu 00041 * US Mail: 1210 W. Dayton Street, Madison, WI 53706 00042 * 00043 * $Id: fixheap.h,v 1.1.1.1 2004/07/03 17:58:17 qedq Exp $ 00044 */ 00045 00046 #ifndef FIXHEAP_H 00047 #define FIXHEAP_H 00048 00049 #include <stdio.h> 00050 #define MALLOC_OVERHEAD 64 00051 00081 typedef struct _FixHeap { 00082 char *name; 00083 unsigned long nodeSize; /* note: nodeSize>=sizeof(void *), for freeList */ 00084 int verbose; 00085 #ifdef FIXED_SIZE_HEAP 00086 unsigned long nodesPerAlloc; 00087 void *freeList; 00088 void *heapAlloc; /* list of allocated blocks */ 00089 #endif /* FIXED_SIZE_HEAP */ 00090 } FixHeap, *FixHeapPtr; 00091 00092 FixHeapPtr FixHeapCreate(char *name, unsigned long nodeSize, 00093 unsigned long nodesPerAlloc, int verbose); 00094 void FixHeapRelease(FixHeapPtr heap); 00095 void *FixHeapMalloc(FixHeapPtr heap); 00096 void FixHeapFree(FixHeapPtr heap, void *node); 00097 00101 #define FIXHEAP_OVERHEAD 32 00102 00111 #define COMPUTE_ALLOC_COUNT(kBytes,Type) \ 00112 (((((kBytes)*1024)-MALLOC_OVERHEAD)-FIXHEAP_OVERHEAD)/sizeof(Type)) 00113 00114 #endif /* FIXHEAP_H */