All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] slob: move kstrdup to lib/string.c
@ 2005-11-01 18:33 Matt Mackall
  2005-11-01 18:33 ` [PATCH 2/2] slob: introduce the SLOB allocator Matt Mackall
  2005-11-02  6:00 ` [PATCH 1/2] slob: move kstrdup to lib/string.c Andrew Morton
  0 siblings, 2 replies; 13+ messages in thread
From: Matt Mackall @ 2005-11-01 18:33 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

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);

^ permalink raw reply	[flat|nested] 13+ messages in thread
* [PATCH 1/2] slob: introduce mm/util.c for shared functions
@ 2005-11-03 23:00 Matt Mackall
  2005-11-03 23:00 ` [PATCH 2/2] slob: introduce the SLOB allocator Matt Mackall
  0 siblings, 1 reply; 13+ messages in thread
From: Matt Mackall @ 2005-11-03 23:00 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

Add mm/util.c for functions common between SLAB and SLOB.

Signed-off-by: Matt Mackall <mpm@selenic.com>

Index: 2.6.14-slob/mm/Makefile
===================================================================
--- 2.6.14-slob.orig/mm/Makefile	2005-11-03 14:40:31.000000000 -0800
+++ 2.6.14-slob/mm/Makefile	2005-11-03 14:48:17.000000000 -0800
@@ -10,7 +10,7 @@ mmu-$(CONFIG_MMU)	:= fremap.o highmem.o 
 obj-y			:= bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \
 			   page_alloc.o page-writeback.o pdflush.o \
 			   readahead.o slab.o swap.o truncate.o vmscan.o \
-			   prio_tree.o $(mmu-y)
+			   prio_tree.o util.o $(mmu-y)
 
 obj-$(CONFIG_SWAP)	+= page_io.o swap_state.o swapfile.o thrash.o
 obj-$(CONFIG_HUGETLBFS)	+= hugetlb.o
Index: 2.6.14-slob/mm/slab.c
===================================================================
--- 2.6.14-slob.orig/mm/slab.c	2005-11-03 14:40:32.000000000 -0800
+++ 2.6.14-slob/mm/slab.c	2005-11-03 14:47:04.000000000 -0800
@@ -2994,20 +2994,6 @@ void kmem_cache_free(kmem_cache_t *cache
 EXPORT_SYMBOL(kmem_cache_free);
 
 /**
- * kzalloc - allocate memory. The memory is set to zero.
- * @size: how many bytes of memory are required.
- * @flags: the type of memory to allocate.
- */
-void *kzalloc(size_t size, gfp_t flags)
-{
-	void *ret = kmalloc(size, flags);
-	if (ret)
-		memset(ret, 0, size);
-	return ret;
-}
-EXPORT_SYMBOL(kzalloc);
-
-/**
  * kfree - free previously allocated memory
  * @objp: pointer returned by kmalloc.
  *
@@ -3598,24 +3584,3 @@ unsigned int ksize(const void *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);
Index: 2.6.14-slob/mm/util.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ 2.6.14-slob/mm/util.c	2005-11-03 14:47:02.000000000 -0800
@@ -0,0 +1,39 @@
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/module.h>
+
+/**
+ * kzalloc - allocate memory. The memory is set to zero.
+ * @size: how many bytes of memory are required.
+ * @flags: the type of memory to allocate.
+ */
+void *kzalloc(size_t size, gfp_t flags)
+{
+	void *ret = kmalloc(size, flags);
+	if (ret)
+		memset(ret, 0, size);
+	return ret;
+}
+EXPORT_SYMBOL(kzalloc);
+
+/*
+ * 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);

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-11-03 23:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-01 18:33 [PATCH 1/2] slob: move kstrdup to lib/string.c Matt Mackall
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
  -- strict thread matches above, loose matches on Subject: below --
2005-11-03 23:00 [PATCH 1/2] slob: introduce mm/util.c for shared functions Matt Mackall
2005-11-03 23:00 ` [PATCH 2/2] slob: introduce the SLOB allocator Matt Mackall

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.