Re: realloc() implicit free() ?
- From: roberson@xxxxxxxxxxxxxxxxxx (Walter Roberson)
- Date: 21 May 2005 22:00:23 GMT
In article <118stl2rjj6c5d5@xxxxxxxxxxxxxxxxxx>,
SM Ryan <wyrmwif@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
># The question is not over-specified if one is concerned about
># whether one is leaking memory. When your datasets are ~1 Gb each
># and you are handling them in a loop, you can't afford to allow memory
># to leak.
>All you can do to prevent leaks is to match frees to allocs; you don't need to
>know how the library is implemented to do that much. It's still leaking
>you're stuck unless you can get the library source code.
That's not ALL you can do: you can also ask questions about paragraphs
that one might have overlooked or which might have been clarified
in addendums that one hasn't seen, which proscribe the behaviour
of library routines so as to remove the ambiguity.
If no-one happens to know the answer, or if the answer is
indeterminate, then one can sometimes write one's own routine that
avoids the indeterminate behaviour. In the case of realloc(),
since it is never -required- that the address be left unchanged,
one can write a replacement for realloc() in terms of malloc(),
a memory copy, and a free(), provided that one knows the current
size of the object at hand.
--
Entropy is the logarithm of probability -- Boltzmann
.
- Follow-Ups:
- Re: realloc() implicit free() ?
- From: Russell Shaw
- Re: realloc() implicit free() ?
- From: SM Ryan
- Re: realloc() implicit free() ?
- References:
- Re: realloc() implicit free() ?
- From: Walter Roberson
- Re: realloc() implicit free() ?
- From: SM Ryan
- Re: realloc() implicit free() ?
- Prev by Date: Re: One struct pointer question
- Next by Date: Re: getting BCC55 to run
- Previous by thread: Re: realloc() implicit free() ?
- Next by thread: Re: realloc() implicit free() ?
- Index(es):
Relevant Pages
|