home *** CD-ROM | disk | FTP | other *** search
- #ifndef __RWFIXMEM_H__
- #define __RWFIXMEM_H__
- pragma push_align_members(64);
-
- /*
- * RWFixedMemory: Very efficient fixed-length subsegment allocations.
- *
- * $Header: E:/vcs/rw/fixmem.h_v 1.4 18 Feb 1992 09:54:22 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/fixmem.h_v $
- *
- * Rev 1.4 18 Feb 1992 09:54:22 KEFFER
- *
- * Rev 1.3 28 Oct 1991 09:12:36 keffer
- * Include path is now <rw/xxx.h>
- *
- * Rev 1.2 08 Sep 1991 18:39:30 keffer
- * stddef.h now has STARTWRAP/ENDWRAP wrapper around it.
- *
- * Rev 1.1 28 Jul 1991 09:55:26 keffer
- * Now includes <stddef.h>
- *
- * Rev 1.0 28 Jul 1991 08:05:36 keffer
- * Initial revision.
- *
- */
-
- #include "rw/defs.h"
- STARTWRAP
- #include <stddef.h> /* Looking for size_t */
- ENDWRAP
-
- #ifdef _Windows
- # include <windows.h>
- #endif
-
- class RWExport RWFixedMemory {
- #ifdef _Windows
- HANDLE hSegment; // The handle of the segment we are managing (Windows only)
- #endif
- char* lpMem; // Pointer to the memory block we are managing
- size_t slotSize; // (Fixed) size of an allocation
- size_t _headerSize; // Size of bitmap header
- unsigned nSlots; // Max number of outstanding allocations
- unsigned headerSize() const { return (unsigned)_headerSize; }
- public:
- void* allocate(); // Make an allocation; init() must have been called first
- void deallocate(void*); // Return it
- void free(); // Return memory to system; do not call if allocations are outstanding!
- void init(size_t slotsize, unsigned nslots); // Initialize self
- RWBoolean isEmpty() const; // Returns FALSE if there are any outstanding allocations
- RWBoolean isValid() const
- {return lpMem!=0;}
- };
-
- pragma pop_align_members();
- #endif
-