Everything
7.5.2 Memory Management Library

The header file for the memory management library is as follows:

-

<new>

Defines the memory allocation/deallocation function.

 

By setting an exception handling function address to the _ec2p_new_handler variable, exception handling can be executed if memory allocation fails. The _ec2p_new_handler is a static variable and the initial value is NULL. If this handler is used, reentrance will be lost.

 

Operations required for the exception handling function:

-

Creates an allocatable area and returns the area.

-

Operations are not prescribed for cases where an area cannot be created.

Type

Definition Name

Description

Type

new_handler

Pointer type to the function that returns a void type.

Variable

_ec2p_new_handler

Pointer to an exception handling function.

Function

void* operator new(size_t size)

Allocates a memory area with a size specified by size.

void* operator new[ ](size_t size)

Allocates an array area with a size specified by size.

void* operator new(
size_t size, void* ptr)

Allocates the area specified by ptr as the memory area.

void* operator new[ ](
size_t size, void* ptr)

Allocates the area specified by ptr as the array area.

void operator delete(void* ptr)

Deallocates the memory area.

void operator delete[ ](void* ptr)

Deallocates the array area.

new_handler set_new_handler(
new_handler new_P)

Sets the exception handling function address (new_P) in _ec2p_new_handler.

 

void* operator new(size_t size)

Allocates a memory area with the size specified by size.

If memory allocation fails and when new_handler is set, new_handler is called.

Return value: If memory allocation succeeds: Pointer to void type

If memory allocation fails: NULL

 

void* operator new[ ](size_t size)

Allocates an array area with the size specified by size.

If memory allocation fails and when new_handler is set, new_handler is called.

Return value: If memory allocation succeeds: Pointer to void type

If memory allocation fails: NULL

 

void* operator new(size_t size, void* ptr)

Allocates the area specified by ptr as the storage area.

Return value: ptr

 

void* operator new[ ](size_t size, void* ptr)

Allocates the area specified by ptr as the array area.

Return value: ptr

 

void operator delete(void* ptr)

Deallocates the storage area specified by ptr.

If ptr is NULL, no operation will be performed.

 

void operator delete[ ](void* ptr)

Deallocates the array area specified by ptr.

If ptr is NULL, no operation will be performed.

 

new_handler set_new_handler(new_handler new_P)

Sets new_P to _ec2p_new_handler.

Return value: _ec2p_new_handler.