On Fri, 2005-08-05 at 10:22 -0500, Dmitry Torokhov wrote: > On 8/5/05, Pekka Enberg <[EMAIL PROTECTED]> wrote: > > This patch converts kcalloc(1, ...) calls to use the new kzalloc() function. > > > > Hi, > > Have you seen the following in include/sound/core? > > ... > #define kmalloc(size, flags) snd_hidden_kmalloc(size, flags) > #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags) > #define kfree(obj) snd_hidden_kfree(obj)
Thanks for the catch, Dmitry. Pekka [PATCH] ALSA: introduce snd_hidden_kzalloc This patch introduces a memory-leak tracking version of kzalloc for ALSA. Signed-off-by: Pekka Enberg <[EMAIL PROTECTED]> --- include/sound/core.h | 2 ++ sound/core/memory.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) Index: 2.6/include/sound/core.h =================================================================== --- 2.6.orig/include/sound/core.h +++ 2.6/include/sound/core.h @@ -291,12 +291,14 @@ void snd_memory_done(void); int snd_memory_info_init(void); int snd_memory_info_done(void); void *snd_hidden_kmalloc(size_t size, unsigned int __nocast flags); +void *snd_hidden_kzalloc(size_t size, unsigned int __nocast flags); void *snd_hidden_kcalloc(size_t n, size_t size, unsigned int __nocast flags); void snd_hidden_kfree(const void *obj); void *snd_hidden_vmalloc(unsigned long size); void snd_hidden_vfree(void *obj); char *snd_hidden_kstrdup(const char *s, unsigned int __nocast flags); #define kmalloc(size, flags) snd_hidden_kmalloc(size, flags) +#define kzalloc(size, flags) snd_hidden_kzalloc(size, flags) #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags) #define kfree(obj) snd_hidden_kfree(obj) #define vmalloc(size) snd_hidden_vmalloc(size) Index: 2.6/sound/core/memory.c =================================================================== --- 2.6.orig/sound/core/memory.c +++ 2.6/sound/core/memory.c @@ -116,15 +116,20 @@ void *snd_hidden_kmalloc(size_t size, un return _snd_kmalloc(size, flags); } +void *snd_hidden_kzalloc(size_t size, unsigned int __nocast flags) +{ + void *ret = _snd_kmalloc(size, flags); + if (ret) + memset(ret, 0, size); + return ret; +} + void *snd_hidden_kcalloc(size_t n, size_t size, unsigned int __nocast flags) { void *ret = NULL; if (n != 0 && size > INT_MAX / n) return ret; - ret = _snd_kmalloc(n * size, flags); - if (ret) - memset(ret, 0, n * size); - return ret; + return snd_hidden_kzalloc(n * size, flags); } void snd_hidden_kfree(const void *obj) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/