V
valdano
I just want to know what is the best way to allocate and deallocate a
memory
with out causing any kind of memory leaks, crashes.
should I use Malloc and then use delete[ ]
for exp:
char *buffer = (char *) malloc(90* sizeof(char));
//do some stuff
delete buffer[];
or it is better to use
char *buffer = new char[90* sizeof(char)];
//do some stuff
free buffer[] //or delete buffer[]
also if anybody has any more tips i can use during building my program
in order to prevent it from crashing due to memory misuse that would
be great
many thanks
memory
with out causing any kind of memory leaks, crashes.
should I use Malloc and then use delete[ ]
for exp:
char *buffer = (char *) malloc(90* sizeof(char));
//do some stuff
delete buffer[];
or it is better to use
char *buffer = new char[90* sizeof(char)];
//do some stuff
free buffer[] //or delete buffer[]
also if anybody has any more tips i can use during building my program
in order to prevent it from crashing due to memory misuse that would
be great
many thanks