LWN.net Logo

The thorny case of kmalloc(0)

The thorny case of kmalloc(0)

Posted Jun 8, 2007 0:41 UTC (Fri) by bronson (subscriber, #4806)
In reply to: The thorny case of kmalloc(0) by HenrikH
Parent article: The thorny case of kmalloc(0)

The article gives a perfectly good reason why kmalloc(0) is a decent thing to do: when the config has resulted in a struct with 0 members. Much easier just to kmalloc(0) and continue as normal rather than scattering more #ifdefs or macros everywhere.

(there's no need to test for ZERO_SIZE_PTR in this case because the struct has no members so the pointer can not be dereferenced anyway; you'll get a compile-time error instead of an oops)


(Log in to post comments)

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds