🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #2235

Re: How to debug in OS/2 with GCC 2.2.2?

#2235
From: Tom J Parry
Date: Fri, 02 Oct 1992 05:23
26 lines
1653 bytes
Wey Jing HO (sci240s@monu6.cc.monash.edu.au) wrote:
> PLEASE HELP ME!!
> 
> 
> Briefly, what I am trying to do:
> 1) declare unsigned char **variable;
> 2) variable = (unsigned char **)malloc(512*sizeof(unsigned char));
													^^^^^^^^^^^^^
BANG! BZZT! That should read (unsigned char *). You want 512 char arrays
not 512 chars. That is why you are getting the violations. If you look at
line 4) of your algorithm, you will see that you are storing (unsigned char
*)'s in the array which is only big enough to hold (unsigned char)'s. Hence
the error. A pointer is 4 bytes long whereas a char is only 1.

> 3) check malloc if == NULL;
> 4) variable[i] = (unsigned char *)malloc(512*sizeof(unsigned char)); 
>    for (i=0; i<512; i++); (sorry, this line should appear first)
> 5) check malloc if == NULL;
> 6) variable[row][col] = (unsigned char)fgetc(instream);
> 
> The program will break with the above SYS errors at row = 256 and col = 0
> (that means it manage to reach row = 255 and col = 511).

-- 
Tom J Parry.
Your reality is a figment of my imagination.
Technical Details
Message-ID: <1992Oct2.052347.28585@monu6.cc.monash.edu.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!monu6!yoyo.cc.monash.edu.au!parry
References: <1992Sep29.190753.4833@monu6.cc.monash.edu.au>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer,comp.os.os2.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!monu6!yoyo.cc.monash.edu.au!parry
From: parry@yoyo.cc.monash.edu.au (Tom J Parry)
Subject: Re: How to debug in OS/2 with GCC 2.2.2?
Message-ID: <1992Oct2.052347.28585@monu6.cc.monash.edu.au>
Originator: parry@yoyo.cc.monash.edu.au
Sender: news@monu6.cc.monash.edu.au (Usenet system)
Organization: Monash University, Melb., Australia.
References: <1992Sep29.190753.4833@monu6.cc.monash.edu.au>
Date: Fri, 2 Oct 1992 05:23:47 GMT
Lines: 26