Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Oct 2002 23:02:50 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Maxime Henrion <mux@freebsd.org>
Cc:        "Vladimir B.  Grebenschikov" <vova@sw.ru>, <freebsd-current@freebsd.org>
Subject:   Re: DDB sysctl function
Message-ID:  <20021009225646.W5232-100000@gamplex.bde.org>
In-Reply-To: <20021009122319.GS57622@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 9 Oct 2002, Maxime Henrion wrote:

> Bruce Evans wrote:
> > On Wed, 9 Oct 2002, Maxime Henrion wrote:
> >
> > > What I meant in my previous mail is that you could malloc() these
> > > objects instead of putting them on the stack.  Also, you don't need
> > > buffers that big since the size you need is bounded at max(sizeof(int),
> > > TOK_STRING_SIZE), which is likely to be TOK_STRING_SIZE :-).
> >
> > ddb can't call malloc() or any other general memory allocation function,
> > since it may be (and often is) invoked in the middle of such functions.
>
> I guess using a buffer of TOK_STRING_SIZE bytes for the tIDENT case and
> int for the tNUMBER case would be best then.  We could use the same
> buffer if we don't plan to support platforms with ints bigger than 120
> bytes :-).

A static buffer should work, since ddb isn't reentrant.  (I first thought
of a malloc() at init time.  That wouldn't work, since ddb may be called
before kvm is initialized.  It could be delayed provided the functions
that use it aren't called early.  But static allocation still works
better.)

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021009225646.W5232-100000>