X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_init.c;h=44bb42faebde164f66de6918b840c01556fd7755;hb=e31cce4d7a8789dc9c0dc723c4c13e719ad2db86;hp=cdb9e66be9d872361df5511a10dc45a1074b57dd;hpb=4cb147e54debc316cb9c142159873ad24e0359ad;p=freeglut diff --git a/src/freeglut_init.c b/src/freeglut_init.c index cdb9e66..44bb42f 100644 --- a/src/freeglut_init.c +++ b/src/freeglut_init.c @@ -211,27 +211,27 @@ static int fghNetWMSupported(void) /* Check if "hint" is present in "property" for "window". */ int fgHintPresent(Window window, Atom property, Atom hint) { - Atom ** atoms_ptr; + Atom *atoms; int number_of_atoms; int supported; int i; supported = 0; - atoms_ptr = malloc(sizeof(Atom *)); number_of_atoms = fghGetWindowProperty(window, property, XA_ATOM, - (unsigned char **) atoms_ptr); + (unsigned char **) &atoms); for (i = 0; i < number_of_atoms; i++) - { - if ((*atoms_ptr)[i] == hint) + { + if (atoms[i] == hint) { supported = 1; break; } - } + } + XFree(atoms); return supported; } @@ -314,7 +314,7 @@ static void fghInitialize( const char* displayName ) /* What we need to do is to initialize the fgDisplay global structure here. */ fgDisplay.Instance = GetModuleHandle( NULL ); - fgDisplay.DisplayName=strdup(displayName); + fgDisplay.DisplayName= displayName ? strdup(displayName) : 0 ; atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc ); if( atom == 0 ) @@ -390,7 +390,12 @@ static void fghInitialize( const char* displayName ) #endif fgState.Initialised = GL_TRUE; + + /* Avoid registering atexit callback on Win32 as it results in an access + * violation due to calling into a module which has been unloaded. */ +#ifndef TARGET_HOST_MS_WINDOWS atexit(fgDeinitialize); +#endif /* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */ fgInitialiseInputDevices();