Re: iphlpapi: Only call res_init() once per process
On Wednesday 18 April 2007 20:39, Hans Leidekker wrote:
+static int resolver_initialised;
Shouldn't that be static int resolver_initilised = 0; here? I thought that in C, ints aren't initialized to 0 automatically.
+/* call res_init() just once because of a bug in Mac OSX 10.4 */ +static void initialise_resolver( void ) +{ + if (!resolver_initialised) + { + res_init(); + resolver_initialised = 1; + } +}
Cheers, Kai -- Kai Blin, <kai Dot blin At gmail Dot com> WorldForge developer http://www.worldforge.org/ Wine developer http://wiki.winehq.org/KaiBlin/ -- Will code for cotton.
On 19/04/07, Kai Blin <kai.blin(a)gmail.com> wrote:
On Wednesday 18 April 2007 20:39, Hans Leidekker wrote:
+static int resolver_initialised;
Shouldn't that be
static int resolver_initilised = 0;
here? I thought that in C, ints aren't initialized to 0 automatically.
Afaik static variables are.
On Thu, 2007-04-19 at 07:49 +0200, Kai Blin wrote:
On Wednesday 18 April 2007 20:39, Hans Leidekker wrote:
+static int resolver_initialised;
Shouldn't that be
static int resolver_initilised = 0;
here? I thought that in C, ints aren't initialized to 0 automatically. Actually I think in this case they would be. Most compilers do this by default IIRC (if you'd like to see for yourself, try the attached test.) Still, I think it would be prudent to put the 0 in there anyway, sine I don't think there's a standard that says compilers have to do this so there could potentially be portability problems.
HTH, James
James Liggett <jrliggett(a)cox.net> writes:
Actually I think in this case they would be. Most compilers do this by default IIRC (if you'd like to see for yourself, try the attached test.) Still, I think it would be prudent to put the 0 in there anyway, sine I don't think there's a standard that says compilers have to do this so there could potentially be portability problems.
There are no potential problems at all, statics are _always_ initialized to 0 in C. -- Alexandre Julliard julliard(a)winehq.org
On Thursday 19 April 2007 23:34, Alexandre Julliard wrote:
James Liggett <jrliggett(a)cox.net> writes:
Actually I think in this case they would be. Most compilers do this by default IIRC (if you'd like to see for yourself, try the attached test.) Still, I think it would be prudent to put the 0 in there anyway, sine I don't think there's a standard that says compilers have to do this so there could potentially be portability problems.
There are no potential problems at all, statics are _always_ initialized to 0 in C.
And another new thing learned about C. Thanks for the explanations. Kai -- Kai Blin, <kai Dot blin At gmail Dot com> WorldForge developer http://www.worldforge.org/ Wine developer http://wiki.winehq.org/KaiBlin/ -- Will code for cotton.
participants (4)
-
Alexandre Julliard -
H. Verbeet -
James Liggett -
Kai Blin