www.delorie.com/archives/browse.cgi | search |
Date: | Sun, 9 Feb 2003 18:57:19 +0100 |
To: | djgpp AT delorie DOT com |
Subject: | Re: allocating big chunks with djgpp |
Message-ID: | <20030209175718.GA31356@sprite.fr.eu.org> |
Mail-Followup-To: | djgpp AT delorie DOT com |
References: | <b25thp$g512 AT imsp212 DOT netvigator DOT com> <200302091726 DOT h19HQxp16523 AT envy DOT delorie DOT com> |
Mime-Version: | 1.0 |
In-Reply-To: | <200302091726.h19HQxp16523@envy.delorie.com> |
User-Agent: | Mutt/1.5.3i |
From: | Jeremie Koenig <sprite AT sprite DOT fr DOT eu DOT org> |
Reply-To: | djgpp AT delorie DOT com |
Errors-To: | nobody AT delorie DOT com |
X-Mailing-List: | djgpp AT delorie DOT com |
X-Unsubscribes-To: | listserv AT delorie DOT com |
On Sun, Feb 09, 2003 at 12:26:59PM -0500, DJ Delorie wrote: > char buffer[30000][81]; Ok > int foo() > { > static char buffer[30000][81]; Ok, too. > char **buffer2 = malloc(30000 * 81); Bad. buffer2[x] will be an uninitialized pointer. Even if you want that (you obviously don't for such purposes) you should include sizeof(buffer2) as a factor of malloc() parameter. The right way, IMHO : char (*buffer)[81] = malloc(sizeof(buffer) * 30000); Which i think will actually work the same as the two above. -- Jeremie Koenig <sprite AT sprite DOT fr DOT eu DOT org>
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |