Slab allocators: consistent ZERO_SIZE_PTR support and NULL result semantics
[linux-2.6-block.git] / include / linux / slab_def.h
index 365d036c454ad11b051f50e8a236fc5de8d9f734..16e814ffab8d2d10449bba71f32b4c8720e2f9f8 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; \