Date: Fri, 12 Jul 2002 13:36:22 -0700 (PDT) From: Julian Elischer <julian@elischer.org> To: =?unknown-8bit?Q?Aur=E9lien?= Nephtali <aurelien.nephtali@wanadoo.fr> Cc: hackers@FreeBSD.org Subject: Re: Kernel space: MALLOC() & TAILQ_*() Message-ID: <Pine.BSF.4.21.0207121336110.53224-100000@InterJet.elischer.org> In-Reply-To: <20020710161342.GA22783@nitrogen>
next in thread | previous in thread | raw e-mail | index | archive | help
did you get answers to this?
On Wed, 10 Jul 2002, [unknown-8bit] Aurélien Nephtali wrote:
> Hi,
>
> I'm new in kernel coding (i'm making a kernel module) so i had to learn how
> to use MALLOC*() macros to get memory, not very difficult in fact. But when
> the moment of making a chained list came, the first difficulty appears :/
> Before, i made chained lists like that:
>
> struct my_type {
> struct my_type *next;
> char elem[32];
> int elem_flags;
> };
>
> struct my_type *ch_list;
>
> struct my_type *add_2_list(char *elem, int flags) {
> struct my_type *chelem;
>
> chelem = (struct my_type *) malloc(sizeof(struct my_type));
> chelem->elem_flags = flags;
> strncpy(chelem->elem, elem, 32);
> chelem->next = (struct my_type *) ch_list;
> ch_list = (struct my_type *) chelem;
>
> return((struct my_type *) chelem);
> }
>
> (sorry if my code disturbs somebody but i want to be very clear)
>
> So my question is: Is there a way to *port* this code to be compatible with
> kernel code ? With MALLOC*() macros, i cannot use this code directly because
> each buffer has his own structure (i mean M_MYBUF)... So i looked at the
> queue(3) manpage ... but i want to know if i can *port* my code before.
>
> -- Aurélien
>
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-hackers" in the body of the message
>
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0207121336110.53224-100000>
