Re: SLUB: Return ZERO_SIZE_PTR for kmalloc(0)

From: John Anthony Kazos Jr.
Date: Tue Jun 05 2007 - 09:58:25 EST


> > The name says exactly what it is. It's not at all dreadful. If we're going
> > to return a special value in the zero-size case (and in only that case) as a
> > valid pointer instead of actually allocating one byte and treating it as
> > zero, what we have is...a zero-size pointer.
>
> No, what we have is a sizeof(pointer) sized pointer pointing to an object of
> size zero. ZERO_SIZE_PTR is butt-ugly. With a really ugly butt.

sizeof(pointer) is the object. ZERO_SIZE_PTR is the value stored in that
object. Would you prefer PTR_TO_ZERO_SIZE_OBJ_VAL?

Maybe you would prefer ZERO_SIZE_OBJ instead. What you have is "a pointer
object which points to a zero-sized object".

What if there were some construct in the kernel that never got deleted?
We'll call it "struct foo * bar_ctl". What would you call a pointer to
this? "bar_ctl_ptr". Or even "foo_ptr". So "ZERO_SIZE_OBJ_PTR" is the most
correct form, and "ZERO_SIZE_PTR" is a convenient shortening. "ZERO_PTR"
is too short and also confuses with NULL because NULL is a zero-value
object, rather than a non-zero--value pointer to a zero-size object.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/