Date: Wed, 10 Jul 2002 18:13:42 +0200 From: =?unknown-8bit?Q?Aur=E9lien?= Nephtali <aurelien.nephtali@wanadoo.fr> To: hackers@FreeBSD.org Subject: Kernel space: MALLOC() & TAILQ_*() Message-ID: <20020710161342.GA22783@nitrogen>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020710161342.GA22783>