RE:more about new with placement

Masaharu Goto (MXJ02154@niftyserve.or.jp)
Sun, 05 Jul 1998 22:02:00 +0900


Xie,

New with placement should be as simple as follows. First, use
'new (arena) TYPE[INDEX];' , second, don't use delete on it.
In this case you use the arena as float, so just don't delete it.
If you want to use the arena as class object, you should use explicit
destructor.

Masaharu Goto

#include <stdio.h>

main()
{
float *test[10000][1000];

for(int i=0;i<10000;i++)
for(int ii=0;ii<1000;ii++)
{ test[i][ii] = new (arena) float[10000];
for(int j=0;j<10000;j++)
test[i][ii][j] = i*j;
}
}