free() frees the allocated memory space pointed to ptr, which must have been returned by a previous call to malloc(), calloc() or realloc(). Otherwise, or if free(ptr) has already been called before, undefined behaviour occurs. If ptr is NULL, no operation is performed.
void free(void *ptr);
char *ptr;
ptr = (char *)calloc(10,sizeof(char));
free(ptr);
memory leak occurs if you are not freeing the allocated memory.
No comments:
Post a Comment