delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/23/17:35:08

From: Antoine Leca <Antoine DOT Leca AT Renault DOT FR>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c
Subject: Re: Functions in struct's... possible? How?
Date: Fri, 22 Aug 1997 13:25:17 +0200
Organization: RENAULT
Lines: 20
Message-ID: <33FD771D.40FF@Renault.FR>
References: <33FCDA5C DOT 2353659F AT execulink DOT com> <01bcaea8$2e22c2a0$e3441ed1 AT crhodes DOT flash DOT net>
NNTP-Posting-Host: pc860205.pdj.renault.fr
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Cliff Rhodes wrote:
> 
> Jeff Weeks <pweeks AT execulink DOT com> wrote
> 
> > char *virt = (char *)malloc(640*480*2);
> 
> Did you ever check the return value from malloc()? I think you will have a
> surprise.

To avoid further surprise, I will add an L after 640 or 480.

I know Jeff probably use djgpp (so 32-bits int), but this is just in case.
It doesn't cost a lot of typing or storage, and it can be *very* big help 
for someone who tries to port this to plain DOS (where 640*480*2 is -40960,
converted to 24576 when casted to size_t)...

OTOH, it can be spurious on a plateforme where long are 64 bits.


Antoine

- Raw text -


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