Re: p = kmalloc(sizeof(*p), )

Alan Cox
2005-09-18T17:21:28Z

On Sul, 2005-09-18 at 19:25 +0300, Denis Vlasenko wrote:
> > #define new_object(foo, gfp) (foo *)kmalloc(sizeof(foo), (gfp))
> >
> > then you can
> >
> > x = new_object(struct frob, GFP_KERNEL)
>
> This will emit a warning if x is not a struct frob*,
> which plain kmalloc doesn't do.

In the programs where I use it a lot (eg AberMUD5) I also in debugging
mode pass in __FILE__ and __LINE__ which can be most handy.