void bla(unsigned char* &buffer, int len)
{
buffer = new buffer[len * 2];
//fill buffer with stuff and do calculations and stuff
}
and in main, I do this (just a dumb example here):
int a = 0;
unsigned char* b;
bla(b, 10);
a += b[5];
bla(b, 11);
a += b[5];
delete[] b;
So basicly, because I called the bla function two times in main, it has been "new"-ed 2 times. Is that OK or can it give a memory leak? And it a good programming practice to use this system with a reference to a pointer?