From jan@swi.psy.uva.nl  Mon Jun  5 10:18:05 2000
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id KAA26729;
	Mon, 5 Jun 2000 10:18:04 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id KAA27255;
	Mon, 5 Jun 2000 10:18:36 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: Mehmet Donderler <mdonder@cs.bilkent.edu.tr>, prolog@swi.psy.uva.nl
Subject: Re: Out of Trail Stack Error!
Date: Mon, 5 Jun 2000 10:13:09 +0200
X-Mailer: KMail [version 1.0.28]
Content-Type: text/plain
References: <Pine.SOL.3.92.1000602191241.8441B-100000@didim>
In-Reply-To: <Pine.SOL.3.92.1000602191241.8441B-100000@didim>
MIME-Version: 1.0
Message-Id: <00060510183503.27098@gollem>
Content-Transfer-Encoding: 8bit

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

