Slab allocators: consistent ZERO_SIZE_PTR support and NULL result semantics
[deliverable/linux.git] / include / linux / slab.h
index 27402fea9b794d5e0f0960dd41bc67069ba4af49..0289ec89300a54fd81e665622e35251632e99c6c 100644 (file)
 #define SLAB_MEM_SPREAD                0x00100000UL    /* Spread some memory over cpuset */
 #define SLAB_TRACE             0x00200000UL    /* Trace allocations and frees */
 
+/*
+ * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests.
+ *
+ * Dereferencing ZERO_SIZE_PTR will lead to a distinct access fault.
+ *
+ * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
+ * Both make kfree a no-op.
+ */
+#define ZERO_SIZE_PTR ((void *)16)
+
+#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) < \
+                               (unsigned long)ZERO_SIZE_PTR)
+
 /*
  * struct kmem_cache related prototypes
  */
This page took 0.025684 seconds and 5 git commands to generate.