yes realloc can be used to shrink the allocated memory. yes the remaining memory will be freed. IF we want to allocate more memory and if there is no enough room in that particular boundary, i will allocate a new block ,copy the contents and free the previous contents
On Thu, Sep 22, 2011 at 10:31 PM, Ankuj Gupta <[email protected]> wrote: > Hi > > I have a doubt in functioning of realloc. Can we use realloc to shrink > the memory already allocated ? If yes, will it also free the left over > memory or programmer has to do it ? Also, while reallocating if it has > to move to some other location does the earlier location gets freed or > is it implementation dependent > > Thanks > Ankuj > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
