All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J.A. Magallon" <jamagallon@able.es>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: "J.A. Magallon" <jamagallon@able.es>,
	Jamie Lokier <jamie@shareable.org>,
	viro@parcelfarce.linux.theplanet.co.uk,
	Rolf Eike Beer <eike-kernel@sf-tec.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RFC][PATCH] kmalloc + memset(foo, 0, bar) = kmalloc0
Date: Fri, 12 Sep 2003 00:25:48 +0200	[thread overview]
Message-ID: <20030911222548.GC7221@werewolf.able.es> (raw)
In-Reply-To: 1063318342.3886.17.camel@dhcp23.swansea.linux.org.uk


On 09.12, Alan Cox wrote:
> On Iau, 2003-09-11 at 22:58, J.A. Magallon wrote:
> > On 09.11, Jamie Lokier wrote:
> > > viro@parcelfarce.linux.theplanet.co.uk wrote:
> > > > Bad choice of name - too easy to confuse with kmalloc().
> > > 
> > > kmalloc_and_zero() would be much clearer.
> > > 
> > 
> > Why not kcalloc() ?
> 
> A kcalloc that also checked for maths overflows would probably
> help avoid various errors and checks against ~0/sizeof(n) in
> drivers we have now
> 

Some time ago when I tried to do some wrappers, I choosed something
like this (k-prefixed here for kernel...):

void* kalloc(size_t size)
void* kvalloc(size_t size,size_t num)
void* kallocz(size_t size) // or kalloc_z, clearer...
void* kvallocz(size_t size,size_t num) // kvalloc_z
void* kfree(void*)

And if you don't hate too much C++

#define knew(mytype) (mytype*)kalloc(sizeof(mytype))
#define kvnew(mytype,n) (mytype*)kvalloc(sizeof(mytype),n)

and so on...
I can tell for sure they clarify the code very much... and you
don't forget the NULL check anymore ;).

-- 
J.A. Magallon <jamagallon@able.es>      \                 Software is like sex:
werewolf.able.es                         \           It's better when it's free
Mandrake Linux release 9.2 (Cooker) for i586
Linux 2.4.23-pre2-jam1m (gcc 3.3.1 (Mandrake Linux 9.2 3.3.1-1mdk))

  reply	other threads:[~2003-09-11 22:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-11 13:40 [RFC][PATCH] kmalloc + memset(foo, 0, bar) = kmalloc0 Rolf Eike Beer
2003-09-11 13:45 ` viro
2003-09-11 14:11   ` Rolf Eike Beer
2003-09-11 17:09   ` Jamie Lokier
2003-09-11 21:58     ` J.A. Magallon
2003-09-11 22:12       ` Alan Cox
2003-09-11 22:25         ` J.A. Magallon [this message]
2003-09-11 13:58 ` Breno Silva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030911222548.GC7221@werewolf.able.es \
    --to=jamagallon@able.es \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=eike-kernel@sf-tec.de \
    --cc=jamie@shareable.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.