[m-dev.] mainline regression: io.buffer vs ISO C

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Dec 26 22:48:27 AEDT 2002


On 24-Dec-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> library/io.m:
>     Fix an ISO C compliance error, where we attempted to cast a (char *)
>     to an (unsigned int).
> 
> Index: library//io.m
> ===================================================================
> RCS file: /home/staff/zs/imp/mercury/library/io.m,v
> retrieving revision 1.284
> diff -u -r1.284 io.m
> --- library//io.m	18 Dec 2002 16:21:07 -0000	1.284
> +++ library//io.m	24 Dec 2002 10:35:14 -0000
> @@ -2125,10 +2125,11 @@
>  	io__alloc_buffer(Size::in, Buffer::buffer_uo),
>  	[will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
>  "{
> -	MR_incr_hp_atomic_msg(Buffer,
> +	MR_maybe_record_allocation(
>  		(Size * sizeof(MR_Char) + sizeof(MR_Word) - 1)
>  			/ sizeof(MR_Word),
>  		MR_PROC_LABEL, ""io:buffer/0"");
> +	Buffer = MR_GC_NEW_ARRAY(MR_Char, Size);

That changes the semantics -- for non-GC grades, this will allocate on
the C heap rather than the Mercury heap, with the result being that the
memory will not get reclaimed on backtracking.  This is bad.
Also, for GC grades, it doesn't mark the block as atomic, which it
definitely should.

Could you please fix that?

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  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