Top "Free" questions

Do not use this tag to refer to free software.

Why is my pointer not null after free?

void getFree(void *ptr) { if(ptr != NULL) { free(ptr); ptr = NULL; } return; } int main() { char *a; a=malloc(10); getFree(a); …

c free
Free allocated memory before return a function

I am trying to return an array using malloc in a function: char* queueBulkDequeue(queueADT queue, unsigned int size) { unsigned …

c pointers malloc free
Do I need to free the strtok resulting string?

Or rather, how does strtok produce the string to which it's return value points? Does it allocate memory dynamically? I …

c free strtok
How to use strtok in C properly so there is no memory leak?

I am somewhat confused by what happens when you call strtok on a char pointer in C. I know that …

c malloc free strtok
When do I need dynamic memory?

Possible Duplicate: Malloc or normal array definition? We learn that there is dynamic memory in C and dynamic variables: #include &…

c memory malloc free
fclose() then free()?

Assume I have the following program: #include <stdio.h> int main () { FILE * pFile; pFile = fopen ("myfile.txt","r"); …

c file memory free fclose
Freeing memory twice

In C and C++, Freeing a NULL pointer will result in nothing done. Still, I see people saying that memory …

c++ c memory-management memory-leaks free
glibc detected, realloc(): invalid pointer

I apologize for the lengthy code. I have a simple question, but I thought I include my code so it …

c malloc free glibc realloc
How bad it is to keep calling malloc() and free()?

I'm sending a text file - client-server breakup the text into packets each of 512 bytes but some packets contain text …

c network-programming malloc free packets
How to free pointer's space in memory?

I have question about pointers in C. Each pointer has 4 bytes in memory (address). When I call malloc() it only …

c pointers memory memory-management free