www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/13/05:55:04

From: urquhart AT netcomuk DOT co DOT uk (Adrian Urquhart)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: More malloc troubles
Date: Thu, 12 Dec 1996 22:07:46 GMT
Organization: NETCOM Internet Ltd.
Lines: 31
Message-ID: <32b081a0.39942489@nntp.netcruiser>
References: <01bbe862$3b6f2780$312549c2 AT default>
NNTP-Posting-Host: dialup-14-24.netcomuk.co.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

"Thomas Harte" <T DOT Harte AT btinternet DOT com> wrote:

>	All right, thanks to all those who helped me last time, but I'm still
>having problems. In DJGPP, before main(), I declare these variables as
>global:-
>
>unsigned char *vbuf ;         
>unsigned char *doublebuffer ; 
>unsigned char *background ;   
>
>	Then, soon as the program starts, I do this :-
>
> unsigned char *vbuf = (unsigned char *)malloc(64000);         
> unsigned char *doublebuffer = (unsigned char *)malloc(64000); 
> unsigned char *background = (unsigned char *)malloc(64000);   

You are decalring your variables twice, and . Try:

vbuf = (unsigned char *)malloc(64000);         
doublebuffer = (unsigned char *)malloc(64000); 
background = (unsigned char*)malloc(64000);   

>	But, it causes a general protection fault every single time! I know I am
>in-experienced, but surely there is something seriously wrong here? It
>compiles without errors but brings down DOS every single time.
>	Once again, thanking people in advance,
>
>		-Thomas

Adrian.

- Raw text -


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