From 353aeff4064acbfb69f31d985392071e1dd6b8d8 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 14 Sep 2007 12:32:49 +0000 Subject: [PATCH] Add kzalloc and kcalloc kernel compatibility functions. --- include/linux/slab.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 include/linux/slab.h diff --git a/include/linux/slab.h b/include/linux/slab.h new file mode 100644 index 00000000..61e50513 --- /dev/null +++ b/include/linux/slab.h @@ -0,0 +1,30 @@ + +#ifndef __COMPAT_LINUX_SLAB_H +#define __COMPAT_LINUX_SLAB_H + +#include +#include + +#include_next + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) + +static inline void *kzalloc(size_t size, unsigned int flags) +{ + void *ret = kmalloc(size, flags); + if (ret) + memset(ret, 0, size); + return ret; +} + +static inline void *kcalloc(size_t n, size_t size, unsigned int flags) +{ + if (n != 0 && size > INT_MAX / n) + return NULL; + return kzalloc(n * size, flags); +} + +#endif + +#endif + -- 2.26.2