Mail Archives: djgpp/1997/01/11/05:17:11
David Stockton wrote:
>
> > John M. Aldrich wrote:
> > All memory that is allocated using sbrk(), malloc(), and its family, is
> > automatically freed by the DJGPP exit code. It is, however, generally
> > good programming to clean things up yourself (although very few
>
> I am not sure I agree with this statement. Why should the user have to
> sit around and wait while some programs traverses all its arrays and
> linked lists freeing memory when it will make no difference at all? I
>
The only case when this can be a problem is if you reuse some of your
code in other applications, or add something to your program. You might
then forget that some variable is not freed.
What I would do about that would be to write the free() statement where
they should be, but comment them out when they are unneeded. If I have to
reuse my functions in another program, the commented free will act as a
reminder.
Francois
- Raw text -