Alexandre Julliard : libwine: Initialize debug channels options on first use.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Sep 11 07:28:43 CDT 2007


Module: wine
Branch: master
Commit: b9304bd64c0364a10cff82ff1ffc4304c7070ada
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b9304bd64c0364a10cff82ff1ffc4304c7070ada

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Sep 11 11:57:11 2007 +0200

libwine: Initialize debug channels options on first use.

---

 libs/wine/debug.c  |   12 ++++++++++--
 libs/wine/loader.c |    2 --
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/libs/wine/debug.c b/libs/wine/debug.c
index 6f4167f..67cc172 100644
--- a/libs/wine/debug.c
+++ b/libs/wine/debug.c
@@ -35,11 +35,13 @@ static const char * const debug_classes[] = { "fixme", "err", "warn", "trace" };
 #define MAX_DEBUG_OPTIONS 256
 
 static unsigned char default_flags = (1 << __WINE_DBCL_ERR) | (1 << __WINE_DBCL_FIXME);
-static unsigned int nb_debug_options = 0;
+static int nb_debug_options = -1;
 static struct __wine_debug_channel debug_options[MAX_DEBUG_OPTIONS];
 
 static struct __wine_debug_functions funcs;
 
+static void debug_init(void);
+
 static int cmp_name( const void *p1, const void *p2 )
 {
     const char *name = p1;
@@ -50,6 +52,8 @@ static int cmp_name( const void *p1, const void *p2 )
 /* get the flags to use for a given channel, possibly setting them too in case of lazy init */
 unsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel )
 {
+    if (nb_debug_options == -1) debug_init();
+
     if (nb_debug_options)
     {
         struct __wine_debug_channel *opt = bsearch( channel->name, debug_options, nb_debug_options,
@@ -65,6 +69,8 @@ unsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel
 int __wine_dbg_set_channel_flags( struct __wine_debug_channel *channel,
                                   unsigned char set, unsigned char clear )
 {
+    if (nb_debug_options == -1) debug_init();
+
     if (nb_debug_options)
     {
         struct __wine_debug_channel *opt = bsearch( channel->name, debug_options, nb_debug_options,
@@ -177,10 +183,12 @@ static void debug_usage(void)
 
 
 /* initialize all options at startup */
-void debug_init(void)
+static void debug_init(void)
 {
     char *wine_debug;
 
+    if (nb_debug_options != -1) return;  /* already initialized */
+    nb_debug_options = 0;
     if ((wine_debug = getenv("WINEDEBUG")))
     {
         if (!strcmp( wine_debug, "help" )) debug_usage();
diff --git a/libs/wine/loader.c b/libs/wine/loader.c
index 9f69a1c..e6fcaae 100644
--- a/libs/wine/loader.c
+++ b/libs/wine/loader.c
@@ -88,7 +88,6 @@ static unsigned int nb_dll_paths;
 static int dll_path_maxlen;
 
 extern void mmap_init(void);
-extern void debug_init(void);
 extern const char *get_dlldir( const char **default_dlldir );
 
 /* build the dll load path from the WINEDLLPATH variable */
@@ -629,7 +628,6 @@ void wine_init( int argc, char *argv[], char *error, int error_size )
     __wine_main_argv = argv;
     __wine_main_environ = environ;
     mmap_init();
-    debug_init();
 
     for (path = first_dll_path( "ntdll.dll", 0, &context ); path; path = next_dll_path( &context ))
     {




More information about the wine-cvs mailing list