Messages in this thread | | | Date | Wed, 1 Aug 2007 20:56:13 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: [RFC PATCH] type safe allocator |
| |
On Wed, 1 Aug 2007, Miklos Szeredi wrote: > > I wonder why we don't have type safe object allocators a-la new() in > C++ or g_new() in glib? > > fooptr = k_new(struct foo, GFP_KERNEL);
I would object to this if only because of the horrible name.
C++ is not a good language to take ideas from, and "new()" was not it's best feature to begin with. "k_new()" is just disgusting.
I'd call it something like "alloc_struct()" instead, which tells you exactly what it's all about. Especially since we try to avoid typedefs in the kernel, and as a result, it's basically almost always a struct thing.
That said, I'm not at all sure it's worth it. Especially not with all the various variations on a theme (zeroed, arrays, etc etc).
Quite frankly, I suspect you would be better off just instrumenting "sparse" instead, and matching up the size of the allocation with the type it gets assigned to.
Linus - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |