[m-dev.] for review: shut up a warning

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jan 18 19:56:19 AEDT 2001


On 18-Jan-2001, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> Here is the updated fix.
> 
> browser/dl.m:
> 	Replace a call to strdup with a call to MR_GC_copy_string.
> 
> runtime/mercury_memory.[ch]:
> 	Declare and define MR_GC_copy_string, which is identical to
> 	MR_copy_string except it calls MR_GC_malloc instead of MR_malloc.

That code has a memory leak in non-conservative GC grades.
In non-conservative GC grades, the memory will get allocated
with malloc(), and never freed.  It should instead get
allocated on the Mercury heap, so that it will get
reclaimed on backtracking (or by the accurate garbage
collector, when that is implemented).

That's why the code should use MR_make_string(), as I suggested
earlier.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list