Phoenix
Object-oriented orthogonally persistent operating system
Defines | Functions
new.h File Reference

Memory allocation operators. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define NEW   ::new(__FILE__, __LINE__)
 Macro to use operator new is required.
#define NEW_ALIGNED(align)   ::new(__FILE__, __LINE__, align)
 Macro for allocating aligned memory.
#define NEW_OPT(...)   ::new(__FILE__, __LINE__, ## __VA_ARGS__)
 Macro for allocating memory with options.
#define DELETE   ::delete
 Macro for invoking delete operator.

Functions

void * __operator_new (size_t size, const char *file, int line, bool isArray=false, size_t align=0)
 Back-end for operator new which should be implemented by each environment.
void * __operator_new (size_t size, bool isArray=false, size_t align=0)
 Back-end for operator new which should be implemented by each environment.
void __operator_delete (void *ptr, bool isArray=false)
 Back-end for operator delete which should be implemented by each environment.
void * operator new (size_t size)
 new operator for untracked allocations.
void * operator new[] (size_t size)
 new operator for untracked arrays allocations.
void * operator new (size_t size, size_t align)
 new operator for untracked allocations with options.
void * operator new[] (size_t size, size_t align)
 new operator for untracked arrays allocations with options.
void * operator new (size_t size, const char *file, int line, size_t align=0)
 new operator for tracked allocations with options.
void * operator new[] (size_t size, const char *file, int line, size_t align=0)
 new operator for tracked arrays allocations with options.
void operator delete (void *ptr)
 delete operator for non-arrays allocations.
void operator delete[] (void *ptr)
 delete operator for arrays allocations.

Detailed Description

Memory allocation operators.


Define Documentation

#define DELETE   ::delete

Macro for invoking delete operator.

#define NEW   ::new(__FILE__, __LINE__)

Macro to use operator new is required.

It will ensure allocations tracking in debug builds.

#define NEW_ALIGNED (   align)    ::new(__FILE__, __LINE__, align)

Macro for allocating aligned memory.

Parameters:
alignMemory block alignment in bytes.
#define NEW_OPT (   ...)    ::new(__FILE__, __LINE__, ## __VA_ARGS__)

Macro for allocating memory with options.


Function Documentation

void __operator_delete ( void *  ptr,
bool  isArray = false 
)

Back-end for operator delete which should be implemented by each environment.

Parameters:
ptrPointer to the memory block being freed.
isArraytrue if delete[] operator was invoked, false otherwise.
void* __operator_new ( size_t  size,
bool  isArray = false,
size_t  align = 0 
)

Back-end for operator new which should be implemented by each environment.

This version is invoked in release builds.

Parameters:
sizeAllocation size.
isArraytrue if new[] operator was invoked, false otherwise.
alignAlignment value. Zero indicates that no specific alignment required.
Returns:
Pointer to allocated memory block.
void* __operator_new ( size_t  size,
const char *  file,
int  line,
bool  isArray = false,
size_t  align = 0 
)

Back-end for operator new which should be implemented by each environment.

This version is invoked in debug builds with source code location in arguments.

Parameters:
sizeAllocation size.
fileSource file name where from the operator is invoked.
lineLine number in the source file where from the operator is invoked.
isArraytrue if new[] operator was invoked, false otherwise.
alignAlignment value. Zero indicates that no specific alignment required.
Returns:
Pointer to allocated memory block.
void operator delete ( void *  ptr) [inline]

delete operator for non-arrays allocations.

Parameters:
ptrPointer to memory block to free.
void operator delete[] ( void *  ptr) [inline]

delete operator for arrays allocations.

Parameters:
ptrPointer to memory block to free.
void* operator new ( size_t  size,
const char *  file,
int  line,
size_t  align = 0 
) [inline]

new operator for tracked allocations with options.

Parameters:
sizeAllocation size.
fileSource file name where from the operator is invoked.
lineLine number in the source file where from the operator is invoked.
alignAlignment value. Zero indicates that no specific alignment required.
Returns:
Pointer to allocated memory block.
void* operator new ( size_t  size) [inline]

new operator for untracked allocations.

Parameters:
sizeAllocation size.
Returns:
Pointer to allocated memory block.
void* operator new ( size_t  size,
size_t  align 
) [inline]

new operator for untracked allocations with options.

Parameters:
sizeAllocation size.
alignAlignment value. Zero indicates that no specific alignment required.
Returns:
Pointer to allocated memory block.
void* operator new[] ( size_t  size,
size_t  align 
) [inline]

new operator for untracked arrays allocations with options.

Parameters:
sizeAllocation size.
alignAlignment value. Zero indicates that no specific alignment required.
Returns:
Pointer to allocated memory block.
void* operator new[] ( size_t  size,
const char *  file,
int  line,
size_t  align = 0 
) [inline]

new operator for tracked arrays allocations with options.

Parameters:
sizeAllocation size.
fileSource file name where from the operator is invoked.
lineLine number in the source file where from the operator is invoked.
alignAlignment value. Zero indicates that no specific alignment required.
Returns:
Pointer to allocated memory block.
void* operator new[] ( size_t  size) [inline]

new operator for untracked arrays allocations.

Parameters:
sizeAllocation size.
Returns:
Pointer to allocated memory block.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines