malloc() in kernel and increasing mbuf and cluster size

Daniel O'Connor doconnor at gsoft.com.au
Mon Oct 17 06:31:19 PDT 2005


On Mon, 17 Oct 2005 21:56, kamal kc wrote:
> the man pages use M_FOOBUF(where did it come from ??)
> in the field type.

'foo' is a generic term for a random variable name.

> Now how should i code it.
>
> struct malloc_type  mytype;
> mytype=MALLOC_DEFINE(.....,"mybuffers","mybuffers");
>
> what should i put in the type field ??

Read the man page!!
/* sys/something/foo_extern.h */

MALLOC_DECLARE(M_FOOBUF);

/* sys/something/foo_main.c */

MALLOC_DEFINE(M_FOOBUF, "foobuffers", "Buffers to foo data into the ether");
/* sys/something/foo_subr.c */

           ...
MALLOC(buf, struct foo_buf *, sizeof *buf, M_FOOBUF, M_NOWAIT);

Read other code, there are plenty of examples in the tree.

-- 
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20051017/27fffb83/attachment.bin


More information about the freebsd-net mailing list