#include <memory>
#include <cstdlib>
#include <cstring>
#include <iostream>
Go to the source code of this file.
|
class | MEMFUN |
| class with overloaded "new" operator initializing object with zeros More...
|
|
|
#define | NEW_TAB(Var, Typ, Len) |
| Macro for initializing array with zeros. More...
|
|
#define | DELETE_(OBJ) |
| Macro for safe deleteing the object and sets the pointer to zero. More...
|
|
#define | DELETE_TAB(OBJ) |
| Macro for safe deleteing the array and sets the pointer to zero. More...
|
|
|
template<class typ > |
void | ERASE (typ **ptr, const char *text="(No name specified)") |
| Safe erasing of the object and sets the pointer to zero. More...
|
|
This file contains some smart functions, operators, macros for safe initializing end erasing the memory
Definition in file memfun.h.
◆ DELETE_
Value:{ \
if( OBJ ) {delete OBJ; OBJ = NULL;} \
}
Macro for safe deleteing the object and sets the pointer to zero.
- Parameters
-
OBJ | - pointer to the object |
Definition at line 85 of file memfun.h.
◆ DELETE_TAB
#define DELETE_TAB |
( |
|
OBJ | ) |
|
Value:{ \
if( OBJ ) std::cerr << " Delete tab: " << #OBJ << " address = " << OBJ << std::endl; \
if( OBJ ) {delete [] OBJ; OBJ = NULL;} \
}
Macro for safe deleteing the array and sets the pointer to zero.
- Parameters
-
OBJ | - pointer to the array |
Definition at line 98 of file memfun.h.
◆ NEW_TAB
#define NEW_TAB |
( |
|
Var, |
|
|
|
Typ, |
|
|
|
Len |
|
) |
| |
Value:{ \
(Var) = new Typ[Len]; \
std::cerr << " Creating object: " << #Var << " address = " << Var << " typ: " << #Typ << " size (type units) = " << Len << std::endl; \
memset( (Var), 0, sizeof(Typ)*(Len) ); \
}
Macro for initializing array with zeros.
- Parameters
-
Var | - pointer to the array |
Typ | - type of array (e.g. double) |
Len | - legth of array |
Definition at line 72 of file memfun.h.
◆ ERASE()
template<class typ >
void ERASE |
( |
typ ** |
ptr, |
|
|
const char * |
text = "(No name specified)" |
|
) |
| |
Safe erasing of the object and sets the pointer to zero.
- Parameters
-
ptr | - reference to the object pointer |
text | - optional comment to be printed to stderr |
Definition at line 52 of file memfun.h.
61 std::cerr <<
"Warning! Pointer to : " << text <<
" is NULL !!! No delete performed" << std::endl;