Subject: Re: Out of Trail Stack Error!

From: Jan Wielemaker <[email-masked]>
Date: Mon, 5 Jun 2000 10:13:09 +0200

On Fri, 02 Jun 2000, Mehmet Donderler wrote:
>Dear all:
>
>I have a PC with 1GB memory and I have set the Local and Trail stacks to
>their maximum as below. I am calling Prolog from a C program and sending
>the arguments -L0 and -T0 to PL_initialise(..). However, I still have a
>message stating that I am out of trail stack. I suspect that I could not
>set the Local and Trail stack to their maximum correctly. I would be very
>grateful if you e-mail me how I could set the stacks to their maximum
>from a C program.

Basically you are doing it right.  Please note however that calling
Prolog from C(++) repeatedly (i.e. in a loop) should generally be
bracketed with PL_open_foreign_frame() and one of the corresponding
destruction functions to force cleanup of the environment.

>/ My C program fragment /////////////////
>
>............
>
>char *plav[3];
>
>...............
>
>plav[0] = argv[0];
>plav[1] = malloc(sizeof(10));
>strcpy(plav[1],"-L0");

This however is not really good.  sizeof(10) is the same as
sizeof(int), generally 4.  It works by accident (-L0 has 3 chars
+ the 0-terminating is 4).  Just use plav[1] = "-L0";

To see whether it worked, simply call statistics/0.  You can
also call PL_toplevel() from your C-code, look around using
the interactive toplevel and continue the C-code by typing the
end-of-file character.

	Regards --- Jan