home *** CD-ROM | disk | FTP | other *** search
- #ifndef __RWMEMPOOL_H__
- #define __RWMEMPOOL_H__
- pragma push_align_members(64);
-
- /*
- * RWMemoryPool: Manages small object pool via inheritance
- *
- * $Header: E:/vcs/rw/mempool.h_v 1.7 18 Feb 1992 09:54:26 KEFFER $
- *
- ****************************************************************************
- *
- * Rogue Wave
- * P.O. Box 2328
- * Corvallis, OR 97339
- * Voice: (503) 754-3010 FAX: (503) 757-6650
- *
- * Copyright (C) 1989, 1990, 1991. This software is subject to copyright
- * protection under the laws of the United States and other countries.
- *
- ***************************************************************************
- *
- * $Log: E:/vcs/rw/mempool.h_v $
- *
- * Rev 1.7 18 Feb 1992 09:54:26 KEFFER
- *
- * Rev 1.6 05 Nov 1991 14:24:50 keffer
- *
- * Rev 1.5 17 Oct 1991 09:13:00 keffer
- * Changed include path to <rw/xxx.h>
- *
- * Rev 1.3 31 Aug 1991 20:40:28 keffer
- * Now includes <stddef.h>, with a STARTWRAP wrapper
- *
- * Rev 1.1 24 Jul 1991 13:06:44 keffer
- * Added pvcs keywords
- *
- */
-
- /*
- * This class maintains a pool of free memory allocations for small objects.
- * Objects inheriting from it will be managed by it. It can greatly improve
- * the performance of objects that are rapidly allocated and deleted, such
- * as nodes in a linked list or binary tree. It can also help memory
- * fragmentation.
- *
- * Two static variables affect its performance:
- *
- * RWMAXPOOLS: The number of different sizes managed. The
- * default (5) will manage objects with sizes
- * from 1 to 10 bytes big. Objects bigger than this
- * will be handled by the operating system.
- *
- * RWPOOLSIZE: The maximum number of objects retained within a size class.
- * Excess objects are returned to the operating system.
- */
-
- #ifndef __RWDEFS_H__
- # include "rw/defs.h"
- #endif
- STARTWRAP
- #include <stddef.h> /* Looking for size_t*/
- ENDWRAP
-
- static const int RWPOOLSIZE = 5;
- static const int RWMAXPOOLS = 5;
-
- class RWExport RWMemoryPool {
- static void* stash[RWMAXPOOLS][RWPOOLSIZE]; // The private stash
- static short nstash[RWMAXPOOLS]; // Number of free objects in each size class.
- public:
- #ifdef TCC_DELETE_SIZE_BUG
- ~RWMemoryPool() { } // Superfluous destructor required for Borland bug
- #endif
- void operator delete(void*, size_t);
- void* operator new(size_t);
- };
-
- pragma pop_align_members();
- #endif
-