How to deallocate memory without using free() in c -



How to deallocate memory without using free() in c -

int main(void) { int *a = malloc(10); homecoming 0; }

how can free memory without using free()?

from manpage:

the realloc() function changes size of memory block pointed ptr size bytes. contents unchanged in range start of part minimum of old , new sizes. if new size larger old size, added memory not initialized. if ptr null, phone call equivalent malloc(size), values of size; if size equal zero, , ptr not null, phone call equivalent free(ptr). unless ptr null, must have been returned before phone call malloc(), calloc() or realloc(). if area pointed moved, free(ptr) done.

so, need phone call realloc() size 0.

realloc(a, 0);

c

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -