delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/06/23:03:01

Xref: news2.mv.net comp.os.msdos.djgpp:5706
From: DHGW39B AT prodigy DOT com (Eric Domazlicky)
Newsgroups: comp.os.msdos.djgpp
Subject: strange GP fault
Date: 6 Jul 1996 21:36:53 GMT
Organization: Prodigy Services Company 1-800-PRODIGY
Lines: 27
Distribution: world
Message-ID: <4rmm9l$26sq@usenetz1.news.prodigy.com>
NNTP-Posting-Host: 192.168.254.73
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'm having trouble getting one of my rountines to work. What I'm trying 
to do is allocate memory to a pointer while in a class constructor 
function and then use that pointer (which was declared as public: in the 
same class) in a C-style function. Like this:

class constructor{
char *mem;
}

constructor::constructor(int num)
{
mem=malloc(num);
}

main()
{
memcpy(whereever,mem,num);
}


The problem is I can't seem to touch that pointer in the class which I 
did allocate memory for without getting a GP fault. I even tried simply 
taking the pointer out of the class and making it a global variable but 
then when I ran my program I just got a message: "Bad Signal Device 
SIGSEV" repeated over and over again. Anyone know what is going wrong 
here??

- Raw text -


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