From: banny52@yahoo.com (Ginny E. Kim)
Subject: Re: Kernel memory
Date: 3 Aug 2001 23:32:45 -0700 [thread overview]
Message-ID: <2f6bec0a.0108032232.74542b9d@posting.google.com> (raw)
In-Reply-To: 3B6AAA99.4E07EB07@zk3.dec.com
Brian Haley <haley@zk3.dec.com> wrote in message news:<3B6AAA99.4E07EB07@zk3.dec.com>...
> "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
I used MALLOC_VAR(), but, I got same result such as MALLOC()....
Is there any other solution like increasing kernel memory?
next prev parent reply other threads:[~2001-08-04 6:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-02 8:02 Kernel memory Ginny E. Kim
2001-08-02 13:01 ` Bob Harris
2001-08-03 4:55 ` Ginny E. Kim
2001-08-03 13:43 ` Brian Haley
2001-08-04 6:32 ` Ginny E. Kim [this message]
2001-08-10 15:48 ` Brian Haley
2001-08-13 5:21 ` Ginny E. Kim
2001-08-13 18:47 ` Brian Haley
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox