B
binaya
Dear all,
Say I allocate a block of memory using the command malloc.I
have a question. Can I deallocate certain portion of it only during
runtime ?
For eg:
Say I allocate 5 pointers to int as below.
link=(int*)malloc(5*sizeof(int))
But during runtime, I find that I only need the front 3 of them.ie
I only need link,link+1 and link+2.
If I don't need link+3 and link+4, can I free these last two
pointers to int using the command free(link+3) ?
If not, then what is the best way to do so ?
Thanking you in advance.
Say I allocate a block of memory using the command malloc.I
have a question. Can I deallocate certain portion of it only during
runtime ?
For eg:
Say I allocate 5 pointers to int as below.
link=(int*)malloc(5*sizeof(int))
But during runtime, I find that I only need the front 3 of them.ie
I only need link,link+1 and link+2.
If I don't need link+3 and link+4, can I free these last two
pointers to int using the command free(link+3) ?
If not, then what is the best way to do so ?
Thanking you in advance.