Re: [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Instead of adding drm_zalloc, why not just use drm_calloc? At the very least just make drm_zalloc a macro that calls drm_calloc. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFG1H5pX1gOwKyEAw8RAuXrAJ9W+Oyaimcedg0LdDqwqfMgX9Gl2QCeM9BM sdiP4BDvLirsYex5hqhHsFc= =/qZb -END PGP SIGNATURE- - 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/
Re: [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement
> Add drm_zalloc(). Ugh. Too fast. Ofcourse this is the correct version. Sorry. Signed-off-by: Mariusz Kozlowski <[EMAIL PROTECTED]> --- linux-2.6.23-rc3-mm1-a/drivers/char/drm/drmP.h 2007-08-27 18:32:26.0 +0200 +++ linux-2.6.23-rc3-mm1-b/drivers/char/drm/drmP.h 2007-08-26 15:34:40.0 +0200 @@ -1125,10 +1125,17 @@ static __inline__ void *drm_calloc(size_ { return kcalloc(nmemb, size, GFP_KERNEL); } + +/** Wrapper around kzalloc() */ +static __inline__ void *drm_zalloc(size_t size, int area) +{ + return kzalloc(size, GFP_KERNEL); +} #else extern void *drm_alloc(size_t size, int area); extern void drm_free(void *pt, size_t size, int area); extern void *drm_calloc(size_t nmemb, size_t size, int area); +extern void *drm_zalloc(size_t size, int area); #endif /[EMAIL PROTECTED]/ --- linux-2.6.23-rc3-mm1-a/drivers/char/drm/drm_memory_debug.h 2007-08-27 18:32:26.0 +0200 +++ linux-2.6.23-rc3-mm1-b/drivers/char/drm/drm_memory_debug.h 2007-08-27 23:28:31.0 +0200 @@ -167,13 +167,24 @@ void *drm_alloc (size_t size, int area) void *drm_calloc (size_t nmemb, size_t size, int area) { void *addr; - addr = drm_alloc (nmemb * size, area); - if (addr != NULL) - memset((void *)addr, 0, size * nmemb); + addr = drm_alloc(nmemb * size, area); + if (addr) + memset(addr, 0, size * nmemb); return addr; } +void *drm_zalloc(size_t size, int area) +{ + void *addr; + + addr = drm_alloc(size, area); + if (addr) + memset(addr, 0, size); + + return addr; +} + void *drm_realloc (void *oldpt, size_t oldsize, size_t size, int area) { void *pt; - 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/
[PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement
Add drm_zalloc(). Signed-off-by: Mariusz Kozlowski <[EMAIL PROTECTED]> drivers/char/drm/drmP.h |7 +++ drivers/char/drm/drm_memory_debug.h | 17 ++--- 2 files changed, 21 insertions(+), 3 deletions(-) --- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drmP.h +++ linux-2.6.23-rc3-mm1/drivers/char/drm/drmP.h @@ -1125,10 +1125,17 @@ static __inline__ void *drm_calloc(size_ { return kcalloc(nmemb, size, GFP_KERNEL); } + +/** Wrapper around kzalloc() */ +static __inline__ void *drm_zalloc(size_t size, int area) +{ + return kzalloc(size, GFP_KERNEL); +} #else extern void *drm_alloc(size_t size, int area); extern void drm_free(void *pt, size_t size, int area); extern void *drm_calloc(size_t nmemb, size_t size, int area); +extern void *drm_zalloc(size_t size, int area); #endif /[EMAIL PROTECTED]/ --- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_memory_debug.h +++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_memory_debug.h @@ -167,13 +167,24 @@ void *drm_alloc (size_t size, int area) void *drm_calloc (size_t nmemb, size_t size, int area) { void *addr; - addr = drm_alloc (nmemb * size, area); - if (addr != NULL) - memset((void *)addr, 0, size * nmemb); + addr = drm_alloc(nmemb * size, area); + if (!addr) + memset(addr, 0, size * nmemb); return addr; } +void *drm_zalloc(size_t size, int area) +{ + void *addr; + + addr = drm_alloc(size, area); + if (!addr) + memset(addr, 0, size); + + return addr; +} + void *drm_realloc (void *oldpt, size_t oldsize, size_t size, int area) { void *pt; -- - 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/