Slab allocators: consistent ZERO_SIZE_PTR support and NULL result semantics
[linux-2.6.git] / include / linux / slab_def.h
index 365d036..16e814f 100644 (file)
@@ -32,6 +32,10 @@ static inline void *kmalloc(size_t size, gfp_t flags)
 {
        if (__builtin_constant_p(size)) {
                int i = 0;
+
+               if (!size)
+                       return ZERO_SIZE_PTR;
+
 #define CACHE(x) \
                if (size <= x) \
                        goto found; \
@@ -58,6 +62,10 @@ static inline void *kzalloc(size_t size, gfp_t flags)
 {
        if (__builtin_constant_p(size)) {
                int i = 0;
+
+               if (!size)
+                       return ZERO_SIZE_PTR;
+
 #define CACHE(x) \
                if (size <= x) \
                        goto found; \
@@ -88,6 +96,10 @@ static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
 {
        if (__builtin_constant_p(size)) {
                int i = 0;
+
+               if (!size)
+                       return ZERO_SIZE_PTR;
+
 #define CACHE(x) \
                if (size <= x) \
                        goto found; \