#include <ustl.h>
Inheritance diagram for ustl::memblock:

Public Member Functions | |
| memblock (void) | |
| Allocates 0 bytes for the internal block. | |
| memblock (const void *p, size_type n) | |
links to p, n. Data can not be modified and will not be freed. | |
| memblock (size_type n) | |
Allocates n bytes for the internal block. | |
| memblock (const cmemlink &b) | |
Links to what b is linked to. | |
| memblock (const memlink &b) | |
Links to what b is linked to. | |
| memblock (const memblock &b) | |
Links to what b is linked to. | |
| virtual | ~memblock (void) |
| virtual void | unlink (void) |
| Unlinks object. | |
| void | assign (const cmemlink &l) |
| const memblock & | operator= (const cmemlink &l) |
| const memblock & | operator= (const memlink &l) |
| const memblock & | operator= (const memblock &l) |
| void | assign (const void *p, size_type n) |
Copies data from p, n. | |
| void | swap (memblock &l) |
Swaps the contents with l. | |
| void | reserve (size_type newSize, bool bExact=true) |
Reallocates internal block to hold at least newSize bytes. | |
| void | resize (size_type newSize, bool bExact=true) |
resizes the block to newSize bytes, reallocating if necessary. | |
| iterator | insert (iterator start, size_type size) |
Shifts the data in the linked block from start to start + n. | |
| iterator | erase (iterator start, size_type size) |
Shifts the data in the linked block from start + n to start. | |
| void | clear (void) |
| size_type | capacity (void) const |
| bool | is_linked (void) const |
| size_type | max_size (void) const |
| void | manage (memlink &l) |
| void | deallocate (void) throw () |
| Frees internal data. | |
| void | manage (void *p, size_type n) |
| void | copy_link (void) |
| "Instantiate" a linked block by allocating and copying the linked data. | |
| void | read (istream &is) |
Reads the object from stream s. | |
| void | read_file (const char *filename) |
Reads the entire file "filename". | |
Static Public Attributes | |
| static const size_type | c_PageSize = 64 |
| The default minimum allocation unit. | |
Protected Member Functions | |
| virtual size_type | minimumFreeCapacity (void) const |
Adds memory management capabilities to memlink. Uses malloc and realloc to maintain the internal pointer, but only if allocated using members of this class, or if linked to using the Manage() member function. Managed memory is automatically freed in the destructor.
| ustl::memblock::~memblock | ( | void | ) | [virtual] |
Frees internal data, if appropriate Only if the block was allocated using resize, or linked to using Manage, will it be freed. Also, Derived classes should call DestructBlock from their destructor, because upstream virtual functions are unavailable at this point and will not be called automatically.
| void ustl::memblock::reserve | ( | size_type | newSize, | |
| bool | bExact = true | |||
| ) |
Reallocates internal block to hold at least newSize bytes.
Additional memory may be allocated, but for efficiency it is a very good idea to call reserve before doing byte-by-byte edit operations. The block size as returned by size() is not altered. reserve will not reduce allocated memory. If you think you are wasting space, call deallocate and start over. To avoid wasting space, use the block for only one purpose, and try to get that purpose to use similar amounts of memory on each iteration.
| void ustl::memblock::manage | ( | void * | p, | |
| size_type | n | |||
| ) |
Assumes control of the memory block p of size n. The block assigned using this function will be freed in the destructor.