From: Jeff Garzik <jgarzik@pobox.com>
To: J?rn Engel <joern@wohnheim.fh-wedel.de>
Cc: Dan Aloni <da-x@gmx.net>,
Linux Kernel List <linux-kernel@vger.kernel.org>
Subject: Re: [BK PATCH] One strdup() to rule them all
Date: Mon, 25 Aug 2003 13:04:41 -0400 [thread overview]
Message-ID: <20030825170441.GA7097@gtf.org> (raw)
In-Reply-To: <20030825163745.GA17608@wohnheim.fh-wedel.de>
On Mon, Aug 25, 2003 at 06:37:45PM +0200, J?rn Engel wrote:
> On Mon, 25 August 2003 19:14:35 +0300, Dan Aloni wrote:
> >
> > While working on the fix to network devices names and sysctl,
> > I fought to urge to create yet another strdup() implementation
> > This came up.
>
> Nice one.
>
> > +/**
> > + * strdup - Allocate a copy of a string.
> > + * @s: The string to copy. Must not be NULL.
> > + *
> > + * returns the address of the allocation, or NULL on
> > + * error.
> > + */
> > +char *strdup(const char *s)
> > +{
> > + char *rv = kmalloc(strlen(s)+1, GFP_KERNEL);
> > + if (rv)
> > + strcpy(rv, s);
> > + return rv;
> > +}
>
> My gut feeling is always afraid when something "must not be NULL",
> someone will ignore this and Bad Things (tm) happen. Is strdup ever
> used such performance critical code that the extra check would hurt?
>
> Apart from that, well done.
Rusty created this patch, a long time ago. :)
Jeff
next prev parent reply other threads:[~2003-08-25 17:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-25 16:14 [BK PATCH] One strdup() to rule them all Dan Aloni
2003-08-25 16:25 ` Jakub Jelinek
2003-08-25 16:34 ` Dan Aloni
2003-08-25 17:05 ` Jeff Garzik
2003-08-25 17:23 ` Dan Aloni
2003-08-25 17:49 ` Andries Brouwer
2003-09-11 16:22 ` Jörn Engel
2003-09-12 1:57 ` Rusty Russell
2003-09-12 3:12 ` Jeff Garzik
2003-09-12 4:16 ` Rusty Russell
2003-09-12 8:49 ` Bernd Petrovitsch
2003-08-25 16:37 ` Jörn Engel
2003-08-25 16:55 ` Dan Aloni
2003-08-25 17:02 ` Jörn Engel
2003-08-25 17:04 ` Jeff Garzik [this message]
2003-08-25 17:08 ` Jörn Engel
2003-08-25 17:22 ` Jeff Garzik
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=20030825170441.GA7097@gtf.org \
--to=jgarzik@pobox.com \
--cc=da-x@gmx.net \
--cc=joern@wohnheim.fh-wedel.de \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox