cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/08/11:51:51

From: DavMac AT iname DOT com (Davin McCall)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: help: void pointers
Date: Sun, 08 Aug 1999 05:06:26 GMT
Organization: Monash Uni
Lines: 37
Distribution: world
Message-ID: <37ad0e94.18907885@newsserver.cc.monash.edu.au>
References: <8UQq3.6777$K%6 DOT 145927 AT news1 DOT rdc2 DOT on DOT home DOT com>
NNTP-Posting-Host: damcc5.halls.monash.edu.au
X-Trace: towncrier.cc.monash.edu.au 934088726 1115 130.194.198.138 (8 Aug 1999 05:05:26 GMT)
X-Complaints-To: abuse AT monash DOT edu DOT au
NNTP-Posting-Date: 8 Aug 1999 05:05:26 GMT
X-Newsreader: Forte Free Agent 1.1/32.230
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sat, 07 Aug 1999 07:04:36 GMT, "YUBS" <jdebever1 AT home DOT com> wrote:

>void pcx_init(void *image, char type)
>{
>    switch (type)
>        {
>            case 's': {
>                            if (!(((pcx_image_ptr)(image->buffer)) = (char
>* )malloc (image->width* image->height)))
>                         }
>        }
>}

Should be: 		     if(!(((pcx_image_ptr)image)->buffer) =
(char *)malloc(((pcx_image_ptr)image)->width *
((pcx_image_ptr)image)->height)) { printf( "error!\n" ); exit(1); }

or something similar. Better still:

void pcx_init(void *image, char type)
{
    switch (type)
        {
            case 's': {
		pcx_image_ptr tempptr = (pcx_image_ptr)image;
                if (!(tempptr->buffer = (char *)malloc (tempptr->width
* tempptr->height))) {
			print( "error!\n" ); exit(1);
		 }
            }
        }
}

Davin.
__________________________________________________________
       *** davmac - sharkin'!! davmac AT iname DOT com ***
my programming page: http://yoyo.cc.monash.edu.au/~davmac/

- Raw text -


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