From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,20b261795a1761e1 X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2001-08-03 06:43:56 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!news.gtei.net!news.compaq.com!news.cpqcorp.net!not-for-mail Message-ID: <3B6AAA99.4E07EB07@zk3.dec.com> From: Brian Haley X-Mailer: Mozilla 4.77 [en] (X11; U; OSF1 V4.0 alpha) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.unix.tru64 Subject: Re: Kernel memory References: <2f6bec0a.0108020002.29080aa8@posting.google.com> <020820010901584492%harris@zk3.dec.com> <2f6bec0a.0108022055.24136296@posting.google.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 03 Aug 2001 09:43:54 -0400 NNTP-Posting-Host: 16.140.64.151 X-Complaints-To: abuse@Compaq.com X-Trace: news.cpqcorp.net 996846234 16.140.64.151 (Fri, 03 Aug 2001 06:43:54 PDT) NNTP-Posting-Date: Fri, 03 Aug 2001 06:43:54 PDT Organization: Compaq Computer Corporation Xref: archiver1.google.com comp.unix.tru64:4062 "Ginny E. Kim" wrote: > > X int statesize = 5737; > > X static state_t **table = NULL; > > X > > X int table_init() > > X { > > X MALLOC(table, state_t **, sizeof(state_t *) * statesize, > > X M_TEMP, M_NOWAIT); > > X ...................... > > X } > > > > MALLOC is used when the size of the storage can be specified as either > > a hard coded constant, a #define contant, or a sizeof(...) constant. > > > > MALLOC_VAR is used when the size of the storage is passed as a > > variable. 'statesize' is a variable and thus you should be using > > MALLOC_VAR > > > > Bob Harris > > I used the size of the storage of MALLOC be specified as a hard coded constant. > For instance, > #define STATESIZE 5737 > statesize = STATESIZE > I don't think 'statesize' is a variable. > MALLOC() in Tru64 V4.0F doesn't have this problem. > Doesn't the type or flag of malloc() have the problem? Bob is absolutely right here, your code has a bug. 'statesize' is a global variable, this means its value can be modified, for example with dbx. For this reason, 'sizeof(state_t *) * statesize' cannot be calculated at compile time, which is what's required if you're using MALLOC. You have had a lot of questions here lately, most of which can be answered by reading the documentation. Please re-read some of it again, you will probably notice a lot of things you didn't see the first time now that you've had a chance to write some code. -Brian --------------------------------------------------- Brian P. Haley Brian.Haley@compaq.com Tru64 UNIX Networking Group