|
|
/*============================================================================= Copyright (C) 2001 Silicon Tao Technology Systems E-mail: SupportWeb: www.silicontao.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =============================================================================*/ /*============================================================================= File Name: STMalloc.h Object Name: STMalloc Programmer Name: Roy Souther By Command of: Silicon Tao Technology Systems License: GNU general public license. See GNU. Day Zero: 02152000, Feburary 15, 2000 Target Platform: Linux Registors Used: Compiler Used: GNU g++ Compiled Settings: Resources Used: Libraries Used: Ports Used: None Title of program: Object library Discription: Provides C++ functionality of malloc and free. Does not free the same memory more then once and reports if memory not freed at destroy time. =============================================================================*/ #ifndef STMalloc_included #define STMalloc_included #include #include #include #include /** * Provides a safe way to allocate and free memory. This object prevents * memory leeks by controlling the allocation and freeing of space. Controled * memory will never be freed twice nore allocated twice. At destroy time any * memory that was not freed will be automaticly freed. * * @short Provides a safe way to allocate and free memory. */ class STMalloc { private: struct TMemControler { void *MemoryAddress; bool Active; int MemorySize; }; TMemControler *Control; STList *ControlList; public: unsigned int LastCellMalloced, LastCellFreed; /** * Constructor */ STMalloc(); /** * Destructor */ ~STMalloc(); /** * Allcates a block of memory and returns a pointer to it. */ void *MemAlloc(int SizeOfMemToAlloc); /** * Frees a memory block that was previously allocated. */ bool MemFree(void *AddressToFree); /** * Tells the number of memory block that have been allocated. * This is not bytes or size of memory, just a count of the number * of time MemAlloc - MemFree where called. */ unsigned int Count(); }; #endif // STMalloc_included
Generated by: root on UtopiaPlanitia.Ept on Mon Dec 10 22:55:12 2001, using kdoc 2.0a53. |