The Exception::Memory::Alloc exception is thrown by LYRIC containers when a
memory allocation failure occurs. The container identifies itself by the who argument, and
indicates the number of items and the item size with arguments nitems, and itemsize.
Computing nitems×itemsize gives the number of bytes the container identified by who
tried to allocate.
Each LYRIC container is likely to throw a Exception::Memory::Alloc exception. To
simplify detection of which class threw this exception, and in which hierarchy, this
exception is caught whenever possible, and re-thrown using Assert, with a constant
false condition. This allows a kind of “tracing” of this exception, especially through
inheritances.
Synopsis
#include <lyric/Exceptions.hpp>
class Exception::Memory::Alloc : public Exception::Memory
{
public:
Exception::Memory::Alloc (Size nitems, Size itemsize, const void* who);
Exception::Memory::Alloc (const Exception::Memory::Alloc& except);
Size nitems () const;
Size itemsize () const;
};
Description
-
Exception::Memory::Alloc (Size nitems, Size itemsize, const void*
who) -
Constructs this memory allocation exception with nitems, and itemsize, the
number of items and the item size the container given by who tried and failed
to allocate. This constructor is used in all LYRIC containers when a memory
allocation failure occurs.
-
Exception::Memory::Alloc (const Exception::Memory::Alloc& except) -
Constructs this memory allocation exception from the given exception. All
properties and data stored in except are copied into this.
-
Size nitems () const -
Returns the number of items the container which threw the exception tried
to allocate.
-
Size itemsize () const -
Returns the size of an item stored in the container which threw the exception.