summaryrefslogtreecommitdiffstats
path: root/sound/core/memory.c
diff options
context:
space:
mode:
authorPaulo Marques <pmarques@grupopie.com>2005-06-23 00:09:02 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-23 09:45:18 -0700
commit543537bd922692bc978e2e356fcd8bfc9c2ee7d5 (patch)
tree0089e3907e7d6c17c01cffc6ea4a8962ed053079 /sound/core/memory.c
parent991114c6fa6a21d1fa4d544abe78592352860c82 (diff)
downloadlinux-543537bd922692bc978e2e356fcd8bfc9c2ee7d5.tar.bz2
[PATCH] create a kstrdup library function
This patch creates a new kstrdup library function and changes the "local" implementations in several places to use this function. Most of the changes come from the sound and net subsystems. The sound part had already been acknowledged by Takashi Iwai and the net part by David S. Miller. I left UML alone for now because I would need more time to read the code carefully before making changes there. Signed-off-by: Paulo Marques <pmarques@grupopie.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'sound/core/memory.c')
-rw-r--r--sound/core/memory.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/sound/core/memory.c b/sound/core/memory.c
index 20860fec9364..c1fb28e84330 100644
--- a/sound/core/memory.c
+++ b/sound/core/memory.c
@@ -184,6 +184,20 @@ void snd_hidden_vfree(void *obj)
snd_wrapper_vfree(obj);
}
+char *snd_hidden_kstrdup(const char *s, int flags)
+{
+ int len;
+ char *buf;
+
+ if (!s) return NULL;
+
+ len = strlen(s) + 1;
+ buf = _snd_kmalloc(len, flags);
+ if (buf)
+ memcpy(buf, s, len);
+ return buf;
+}
+
static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer)
{
snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc);
@@ -214,36 +228,9 @@ int __exit snd_memory_info_done(void)
return 0;
}
-#else
-
-#define _snd_kmalloc kmalloc
-
#endif /* CONFIG_SND_DEBUG_MEMORY */
/**
- * snd_kmalloc_strdup - copy the string
- * @string: the original string
- * @flags: allocation conditions, GFP_XXX
- *
- * Allocates a memory chunk via kmalloc() and copies the string to it.
- *
- * Returns the pointer, or NULL if no enoguh memory.
- */
-char *snd_kmalloc_strdup(const char *string, int flags)
-{
- size_t len;
- char *ptr;
-
- if (!string)
- return NULL;
- len = strlen(string) + 1;
- ptr = _snd_kmalloc(len, flags);
- if (ptr)
- memcpy(ptr, string, len);
- return ptr;
-}
-
-/**
* copy_to_user_fromio - copy data from mmio-space to user-space
* @dst: the destination pointer on user-space
* @src: the source pointer on mmio