Garfield++
v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
ReplaceAlloc.h
Go to the documentation of this file.
1
#ifndef REPLACE_ALLOC_H
2
#define REPLACE_ALLOC_H
3
4
/* This macro allows to replace standard new and delete for objects
5
of particular class to any non-standard operators, in the example below
6
it is ordinary malloc and free.
7
*/
8
#include <stdlib.h>
9
10
#define macro_alloc \
11
public: \
12
void* operator new(size_t size, void* adr = NULL) { \
13
if (adr == NULL) return malloc(size); \
14
return adr; \
15
} \
16
void* operator new[](size_t size, void* adr = NULL) { \
17
if (adr == NULL) return malloc(size); \
18
return adr; \
19
} \
20
void operator delete(void * f) { free(f); } \
21
void operator delete[](void * f) { free(f); }
22
23
#endif
garfieldpp-v1r0
Heed
wcpplib
safetl
ReplaceAlloc.h
Generated by
1.9.6