[m-dev.] diff: allow multiple commands on one line in the browser

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Aug 27 03:56:37 AEDT 2000


On 26-Aug-2000, Mark Anthony BROWN <dougl at cs.mu.OZ.AU> wrote:
> 
> +:- pragma c_code(util__trace_get_command(Prompt::in, Line::out, MdbIn::in,
> +			MdbOut::in, State0::di, State::uo),
> +	[will_not_call_mercury],
> +	"
> +		char		*line;
> +		char		*mercury_string;
> +		MercuryFile	*mdb_in = (MercuryFile *) MdbIn;
> +		MercuryFile	*mdb_out = (MercuryFile *) MdbOut;
> +
> +		if (MR_address_of_trace_getline != NULL) {
> +			line = (*MR_address_of_trace_get_command)(
> +					(char *) Prompt,
> +					MR_file(*mdb_in), MR_file(*mdb_out));
> +		} else {
> +			MR_tracing_not_enabled();
> +			/* not reached */
> +		}
> +
> +		MR_make_aligned_string_copy(mercury_string, line);
> +		free(line);

You should use MR_free() rather than free(),
since the memory was allocated with MR_malloc().
(It doesn't make any difference now, since MR_free() just calls free(),
but we might later change MR_free(), e.g. to use a debugging allocator.)

> +		Line = (String) mercury_string;

That cast should not be necessary.

> --- trace/mercury_trace_internal.c	2000/08/25 09:53:36	1.75
...
> +char *
> +MR_trace_get_command(const char *prompt, FILE *mdb_in, FILE *mdb_out)
> +{

You should include some documentation about what this function does.
The function's documentation should in particular specify that the
memory returned is allocated via MR_malloc() and it is the caller's
responsibility to deallocate it using MR_free().

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- 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