From: Jakub Jelinek <jakub@redhat.com>
To: Dan Aloni <da-x@gmx.net>
Cc: Linux Kernel List <linux-kernel@vger.kernel.org>
Subject: Re: [BK PATCH] One strdup() to rule them all
Date: Mon, 25 Aug 2003 12:25:32 -0400 [thread overview]
Message-ID: <20030825122532.J10720@devserv.devel.redhat.com> (raw)
In-Reply-To: <20030825161435.GB8961@callisto.yi.org>; from da-x@gmx.net on Mon, Aug 25, 2003 at 07:14:35PM +0300
On Mon, Aug 25, 2003 at 07:14:35PM +0300, Dan Aloni wrote:
> diff -Nru a/lib/string.c b/lib/string.c
> --- a/lib/string.c Mon Aug 25 19:03:26 2003
> +++ b/lib/string.c Mon Aug 25 19:03:26 2003
> @@ -582,3 +582,19 @@
> }
>
> #endif
> +
> +/**
> + * 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;
> +}
> +EXPORT_SYMBOL(strdup);
Better save strlen(s)+1 in a local size_t variable and use memcpy instead
of strcpy.
Jakub
next prev parent reply other threads:[~2003-08-25 16:25 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 [this message]
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
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=20030825122532.J10720@devserv.devel.redhat.com \
--to=jakub@redhat.com \
--cc=da-x@gmx.net \
--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