delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/26/23:30:29

Mime-Version: 1.0
To: leger_v AT bluewin DOT ch, djgpp AT delorie DOT com
From: Nate Eldredge <nate AT cartsys DOT com>
Subject: Re: Problem with malloc() and integers
Date: Sun, 26 Apr 1998 20:23:09 -0700
Message-ID: <19980427032245.AAI5484@ppp100.cartsys.com>

At 09:44  4/26/1998 +0200, leger_v AT bluewin DOT ch wrote:
>Than a lot. I couldn't continue my program without the malloc(long) 
>function. I believed that the (unsigned long *) provided a long
>allocation but I got wrong.

`malloc' has no way of knowing what type you are going to store in the
memory, and the (unsigned long *) bit is just a cast (for more info on which
see a C book).

Incidentally, you should also check in each case whether `malloc' returns
NULL, because you don't really know how much memory is available. It might
be less than (64K * 4 * 10).

Nate Eldredge
nate AT cartsys DOT com



- Raw text -


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