What is a Memory Heap?
What is a memory heap ? 8 Answers 8
What is a memory heap ? 8 Answers 8
It’s known that calloc is different than malloc in that it initializes the memory allocated. With calloc, the memory is set to zero. … 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
alloca() allocates memory on the stack rather than on the heap, as in the case of malloc(). So, when I return from the … Read more
I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should … 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
What is the difference between doing: ptr = malloc (MAXELEMS * sizeof(char *)); or: ptr = calloc (MAXELEMS, sizeof(char*)); When is it a … Read more
In this question, someone suggested in a comment that I should not cast the result of malloc. i.e., I should do this: int … Read more
TL;DR int *sieve = (int *) malloc(sizeof(int) * length); Has two problems in result of malloc. The cast and that you’re using the … Read more