lkml.org 
[lkml]   [2004]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Document kfree and vfree NULL usage
Marcel Sebek wrote:
> On Sat, Nov 27, 2004 at 04:26:00PM +0200, Pekka Enberg wrote:
>
>>Hi,
>>
>>This patch adds comments for kfree() and vfree() stating that both accept
>>NULL pointers. I audited vfree() callers and there seems to be lots of
>>confusion over this in the kernel.
>>
> I've cleaned up sound/ directory from "if (x) {k/v}free(x);" and similar
> constructions. I'm going to to this for most of the kernel if I found
> some time.

Isn't 'if (x) { free(x); }' faster than the call to free() with a NULL
pointer?
What about a macro ?
#define fast_free(x) if (x) { free(x); }
Or even
#define kfree(x) if (x) { _kfree(x); }
Or maybe a inline function so it doesn't break existing code.
inline void kfree(x) { if (x) { _kfree(x); } }

tom
-
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/

\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.181 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site