From owner-freebsd-hackers Wed Jul 10 9:16:17 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D6B2B37B400 for ; Wed, 10 Jul 2002 09:16:14 -0700 (PDT) Received: from nitrogen.wanadoo.fr (ca-sqy-3-156.abo.wanadoo.fr [80.8.56.156]) by mx1.FreeBSD.org (Postfix) with ESMTP id AD80443E42 for ; Wed, 10 Jul 2002 09:16:13 -0700 (PDT) (envelope-from dak@nitrogen.wanadoo.fr) Received: from nitrogen.wanadoo.fr (nitrogen [127.0.0.1]) by nitrogen.wanadoo.fr (8.12.5/8.12.5) with ESMTP id g6AGDgbj022844 for ; Wed, 10 Jul 2002 18:13:45 +0200 (CEST) (envelope-from dak@nitrogen.wanadoo.fr) Received: (from dak@localhost) by nitrogen.wanadoo.fr (8.12.5/8.12.5/Submit) id g6AGDgur022843 for hackers@FreeBSD.org; Wed, 10 Jul 2002 18:13:42 +0200 (CEST) Date: Wed, 10 Jul 2002 18:13:42 +0200 From: =?unknown-8bit?Q?Aur=E9lien?= Nephtali To: hackers@FreeBSD.org Subject: Kernel space: MALLOC() & TAILQ_*() Message-ID: <20020710161342.GA22783@nitrogen> Mime-Version: 1.0 Content-Type: text/plain; charset=unknown-8bit Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.1i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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