From: Ian Abbott Date: Fri, 14 Sep 2007 12:32:49 +0000 (+0000) Subject: Add kzalloc and kcalloc kernel compatibility functions. X-Git-Tag: r0_7_75~33 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=353aeff4064acbfb69f31d985392071e1dd6b8d8;p=comedi.git Add kzalloc and kcalloc kernel compatibility functions. --- 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 +