Buffers
▪Avoid allocating buffers with new/malloc. Buffers are perfectly modeled with std::vector
▪Avoid allocating buffers with new/malloc. Buffers are perfectly modeled with std::vector
▪Prefer the stack for temp buffers, if the size is <=500-1000 bytes
char* temparray = (char*)malloc(10);
memset(temparray, 0, 10); //no need for memset!!!
strcpy(temparray, value.c_str()); //leak!!!
std::vector<char> temparray(10);
strcpy(&temparray[0], value.c_str());
char temparray[10];
strcpy(temparray, value.c_str());