From: Liche <liche AT tp DOT silkera DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Problems with pointers
Date: Fri, 30 Jan 1998 18:48:32 +0800
Organization: New Silkera Network
Lines: 36
Message-ID: <34D1B000.9EFD50DF@tp.silkera.net>
NNTP-Posting-Host: ts141.tp.silkera.net
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Precedence: bulk

I'm not sure if this problem has to do with the DJGPP compiler, but it
may, so please don't flame me for posts that should go somewhere else.
I am trying to write a simple program that will read in a PCX file of
resolution 320x200, decompile it, and display it to screen.  I have a
class PCXimage which is the basic structure of a PCX file, as follows:

class PCXimage
{
   private:
  PCXheader header;
  RGB palette[256];
 public:
      unsigned char* imagebuffer;
    PCXimage();
      ~PCXimage();
    void load(char *filename, int enable_palette);
      void showbuffer();
};

The constructor allocates 64000 bytes via malloc to imagebuffer.  The
destructor frees this.  load loads a file into the buffer, and I believe
that works correctly.  The problem comes when I call showbuffer():

void PCXimage::showbuffer()
{
     dosmemput(imagebuffer, 64000, video_buffer);
}

A general protection fault occurs, and the program terminates.
video_buffer is an
unsigned char * to 0xA0000, the physical address of VGA memory.
Does anybody know how to resolve this problem? Please email me for the
complete source.  Thanks

Liche