allocate()

This function allocates and returns the specified amount of memory.

Syntax

virtual void *allocate(const size_t sz, bool array=false)

Description

The allocate() function allocates memory from the heap for the CPad. The only size restriction is the amount of heap memory that is available.

Note: Use this function only if you are creating or modifying C-style code and want to allocate memory as you would with a call to malloc or calloc. Otherwise (for example, if you are creating or modifying C++ code and want to allocate memory as you would with a call to new), use instead the PAD_NEW macro, which allocates memory and manages constructors (see PAD_NEW()).

Exceptions

This function throws an exception if it cannot allocate the memory.