Setting variable to NULL after free
In my company there is a coding rule that says, after freeing any memory, reset the variable to NULL. For example … void … Read more
In my company there is a coding rule that says, after freeing any memory, reset the variable to NULL. For example … void … Read more
I want to know how malloc and free work. int main() { unsigned char *p = (unsigned char*)malloc(4*sizeof(unsigned char)); memset(p,0,4); strcpy((char*)p,”abcdabcd”); // **deliberately … Read more
In C programming, you can pass any kind of pointer you like as an argument to free, how does it know the size … Read more
We are all taught that you MUST free every pointer that is allocated. I’m a bit curious, though, about the real cost of … Read more