From: Matt Mackall <mpm@selenic.com>
To: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] slob: move kstrdup to lib/string.c
Date: Tue, 1 Nov 2005 12:33:12 -0600 [thread overview]
Message-ID: <2.494767362@selenic.com> (raw)
This move kstrdup to lib/string.c. This a) matches its declaration in
string.h and b) avoids having to duplicate it for SLOB.
(this work has been sponsored in part by CELF)
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: 2.6.14-slob/lib/string.c
===================================================================
--- 2.6.14-slob.orig/lib/string.c 2005-10-31 13:04:50.000000000 -0800
+++ 2.6.14-slob/lib/string.c 2005-10-31 18:14:39.000000000 -0800
@@ -23,6 +23,7 @@
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/module.h>
+#include <linux/slab.h>
#ifndef __HAVE_ARCH_STRNICMP
/**
@@ -602,3 +603,25 @@ void *memchr(const void *s, int c, size_
}
EXPORT_SYMBOL(memchr);
#endif
+
+/*
+ * kstrdup - allocate space for and copy an existing string
+ *
+ * @s: the string to duplicate
+ * @gfp: the GFP mask used in the kmalloc() call when allocating memory
+ */
+char *kstrdup(const char *s, gfp_t gfp)
+{
+ size_t len;
+ char *buf;
+
+ if (!s)
+ return NULL;
+
+ len = strlen(s) + 1;
+ buf = kmalloc(len, gfp);
+ if (buf)
+ memcpy(buf, s, len);
+ return buf;
+}
+EXPORT_SYMBOL(kstrdup);
Index: 2.6.14-slob/mm/slab.c
===================================================================
--- 2.6.14-slob.orig/mm/slab.c 2005-10-31 13:04:50.000000000 -0800
+++ 2.6.14-slob/mm/slab.c 2005-10-31 18:14:43.000000000 -0800
@@ -3596,26 +3596,3 @@ unsigned int ksize(const void *objp)
return obj_reallen(GET_PAGE_CACHE(virt_to_page(objp)));
}
-
-
-/*
- * kstrdup - allocate space for and copy an existing string
- *
- * @s: the string to duplicate
- * @gfp: the GFP mask used in the kmalloc() call when allocating memory
- */
-char *kstrdup(const char *s, gfp_t gfp)
-{
- size_t len;
- char *buf;
-
- if (!s)
- return NULL;
-
- len = strlen(s) + 1;
- buf = kmalloc(len, gfp);
- if (buf)
- memcpy(buf, s, len);
- return buf;
-}
-EXPORT_SYMBOL(kstrdup);
next reply other threads:[~2005-11-01 18:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-01 18:33 Matt Mackall [this message]
2005-11-01 18:33 ` [PATCH 2/2] slob: introduce the SLOB allocator Matt Mackall
2005-11-01 20:51 ` Rob Landley
2005-11-01 21:06 ` Matt Mackall
2005-11-02 6:00 ` [PATCH 1/2] slob: move kstrdup to lib/string.c Andrew Morton
2005-11-02 7:03 ` Matt Mackall
2005-11-02 6:40 ` Andrew Morton
2005-11-02 9:17 ` Paul Mackerras
2005-11-02 13:04 ` Olaf Hering
2005-11-02 14:14 ` Tom Rini
2005-11-02 14:19 ` Olaf Hering
2005-11-02 14:31 ` Tom Rini
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=2.494767362@selenic.com \
--to=mpm@selenic.com \
--cc=akpm@osdl.org \
--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