#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) |
const memblock & | operator= (const cmemlink &b) |
Allocates enough space and copies the contents of b . | |
const memblock & | operator= (const memlink &b) |
Allocates enough space and copies the contents of b . | |
const memblock & | operator= (const memblock &b) |
Allocates enough space and copies the contents of b . | |
void | assign (const void *p, size_type n) |
Copies data from p , n . | |
void | assign (const cmemlink &l) |
Copies data from l . | |
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 | pop_back (void) |
Removes the last element (elementSize() bytes). | |
void | clear (void) |
Resizes the block to 0. | |
void | deallocate (void) |
Frees internal data. | |
void | manage (void *p, size_type n) |
void | manage (memlink &l) |
Assumes control over block pointed to by l . | |
size_type | capacity (void) const |
Returns the number of bytes allocated. | |
virtual void | unlink (void) |
Unlinks object. | |
size_type | max_size (void) const |
Returns the maximum possible size of the block. | |
void | read (istream &is) |
Reads the object from stream s . | |
void | read_file (const char *filename) |
Reads the entire file "filename" . | |
bool | is_linked (void) const |
Returns true if the storage is linked, false if allocated. | |
Static Public Attributes | |
const size_type | c_PageSize = 64 |
The default minimum allocation unit. | |
Protected Member Functions | |
virtual size_type | minimumFreeCapacity (void) const |
Do not use or override this! It exists only for implementing #string. |
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.
|
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. |
|
Assumes control of the memory block |
|
Reallocates internal block to hold at least 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. |