00001 /*========================================================================== 00002 * Copyright (c) 2001 Carnegie Mellon University. All Rights Reserved. 00003 * 00004 * Use of the Lemur Toolkit for Language Modeling and Information Retrieval 00005 * is subject to the terms of the software license set forth in the LICENSE 00006 * file included with this software, and also available at 00007 * http://www.cs.cmu.edu/~lemur/license.html 00008 * 00009 *========================================================================== 00010 */ 00011 00012 00013 #ifndef _MEMLISTH_ 00014 #define _MEMLISTH_ 00015 00016 class MemList { 00017 public: 00018 MemList(int incr, int align=8); 00019 void Reset(); 00020 int NumberOfSegments() const { return numSegments; } 00021 int Used() const { return (((int)curp) - ((int)p)) + Total(); } 00022 int Total() const 00023 { 00024 int total = ((int)endp) - ((int)p); 00025 for (MemList *curml = next; curml; curml = curml->next) 00026 total += ((int)curml->endp) - ((int)curml->p); 00027 return total; 00028 } 00029 ~MemList(); 00030 void *GetMem(int size); 00031 00032 private: 00033 int numSegments; 00034 int increment; 00035 int alignment; 00036 char *p; 00037 char *curp; 00038 char *endp; 00039 MemList *next; 00040 }; 00041 00042 #endif 00043