delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/05/07:50:21

Date: Tue, 5 Oct 1999 09:58:26 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: hank_heng AT hotmail DOT com
cc: djgpp AT delorie DOT com
Subject: Re: gettex() and puttext() problem.
In-Reply-To: <7tbjvd$vve$1@nnrp1.deja.com>
Message-ID: <Pine.SUN.3.91.991005095809.2899O-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 5 Oct 1999 hank_heng AT hotmail DOT com wrote:

> I try to debug it with "symify", it point back to the end of file is
> causing error, this does not make any sense at all...

It *will* make sense if you read section 12.2 of the DJGPP FAQ list,
which specifically mentions the case where the traceback points to the
closing brace of a function, or to its return statement.  The reason
for this is that you write over the return address on the stack by
overwriting some local variable.

> main()
> {
>   int test=3;
>   char destination;
>   void *des = &destination;
> 
> 
>   /* capture screen character */
>   test = gettext(10, 10, 20, 20, des);

And here's the villain: `destination' is declared `char', so only
a single-byte storage is allocated for it.  But `gettext' needs that
its last argument point to a buffer large enough to hold all the
characters retrieved from the screen portion specified by the other
arguments.  In your case, you need 10*10*2 = 200 bytes.

The following should make this work (warning: untested!):

    void *des = malloc (200);

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019