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: cbouatmai...@gmail.com irc://irc.freenode.net/bd2 _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev