Subject: Re: [PATCH 2/3 v3] P4080/mtd: Only make elbc nand driver detect nand flash partitions

From: Anton Vorontsov <[email-masked]>
Date: Thu, 16 Sep 2010 14:14:29 +0400

On Thu, Sep 16, 2010 at 06:08:14PM +0800, Zang Roy-R61911 wrote:
[...]
> Interesting.
> How about this?
> #include <stdio.h>
> #include <malloc.h>
> 
> char *foo;
> 
> void probe(void)
> {
>         char *bar = NULL;
> 
>         if (!foo) {
>                 bar = malloc(sizeof(*bar));
>                 if (!bar)
>                         return;
>                 foo = bar;
>         } else
> 		   bar = foo;

This willl work of course; but I'd write it as

foo_lock();
if (!foo)
	foo = alloc();
foo_unlock();

bar = foo;
bar->baz;

-- 
Anton Vorontsov
email: [email-masked]
irc://irc.freenode.net/bd2