more valgrind errors fixed. Plus I ran make indent which changed a few files.
authorBob Pendleton <bob@pendleton.com>
Fri, 07 Mar 2008 17:20:37 +0000
changeset 23243202e4826c57
parent 2323 4ac07ae446d3
child 2325 c7bcf84ba1b9
more valgrind errors fixed. Plus I ran make indent which changed a few files.
src/video/SDL_video.c
src/video/win32/SDL_win32events.c
src/video/win32/SDL_win32keyboard.c
src/video/x11/SDL_x11events.c
src/video/x11/SDL_x11opengl.c
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11video.h
src/video/x11/SDL_x11window.c
     1.1 --- a/src/video/SDL_video.c	Thu Mar 06 23:07:02 2008 +0000
     1.2 +++ b/src/video/SDL_video.c	Fri Mar 07 17:20:37 2008 +0000
     1.3 @@ -2190,6 +2190,11 @@
     1.4              display->windows = NULL;
     1.5          }
     1.6          display->num_windows = 0;
     1.7 +        if (display->render_drivers) {
     1.8 +            SDL_free(display->render_drivers);
     1.9 +            display->render_drivers = NULL;
    1.10 +        }
    1.11 +        display->num_render_drivers = 0;
    1.12      }
    1.13      _this->VideoQuit(_this);
    1.14  
     2.1 --- a/src/video/win32/SDL_win32events.c	Thu Mar 06 23:07:02 2008 +0000
     2.2 +++ b/src/video/win32/SDL_win32events.c	Fri Mar 07 17:20:37 2008 +0000
     2.3 @@ -36,7 +36,7 @@
     2.4  #define REPEATED_KEYMASK    (1<<30)
     2.5  #define EXTENDED_KEYMASK    (1<<24)
     2.6  
     2.7 -#define VK_ENTER    10  /* Keypad Enter ... no VKEY defined? */
     2.8 +#define VK_ENTER    10          /* Keypad Enter ... no VKEY defined? */
     2.9  
    2.10  /* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
    2.11  #ifndef WM_XBUTTONDOWN
    2.12 @@ -53,7 +53,7 @@
    2.13  RemapVKEY(WPARAM wParam, LPARAM lParam)
    2.14  {
    2.15      int i;
    2.16 -    BYTE scancode = (BYTE)((lParam >> 16) & 0xFF);
    2.17 +    BYTE scancode = (BYTE) ((lParam >> 16) & 0xFF);
    2.18  
    2.19      /* Windows remaps alphabetic keys based on current layout.
    2.20         We try to provide USB scancodes, so undo this mapping.
    2.21 @@ -72,7 +72,7 @@
    2.22      /* Keypad keys are a little trickier, we always scan for them. */
    2.23      for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
    2.24          if (scancode == keypad_scancodes[i]) {
    2.25 -            wParam = VK_NUMPAD0+i;
    2.26 +            wParam = VK_NUMPAD0 + i;
    2.27              break;
    2.28          }
    2.29      }
     3.1 --- a/src/video/win32/SDL_win32keyboard.c	Thu Mar 06 23:07:02 2008 +0000
     3.2 +++ b/src/video/win32/SDL_win32keyboard.c	Fri Mar 07 17:20:37 2008 +0000
     3.3 @@ -53,18 +53,21 @@
     3.4      int i;
     3.5  
     3.6      /* Make sure the alpha scancodes are correct.  T isn't usually remapped */
     3.7 -    if (MapVirtualKey('T', MAPVK_VK_TO_VSC) != alpha_scancodes['T'-'A']) {
     3.8 -printf("Fixing alpha scancode map, assuming US QWERTY layout!\nPlease send the following 26 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
     3.9 +    if (MapVirtualKey('T', MAPVK_VK_TO_VSC) != alpha_scancodes['T' - 'A']) {
    3.10 +        printf
    3.11 +            ("Fixing alpha scancode map, assuming US QWERTY layout!\nPlease send the following 26 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
    3.12          for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
    3.13 -            alpha_scancodes[i] = MapVirtualKey('A'+i, MAPVK_VK_TO_VSC);
    3.14 -printf("%d = %d\n", i, alpha_scancodes[i]);
    3.15 +            alpha_scancodes[i] = MapVirtualKey('A' + i, MAPVK_VK_TO_VSC);
    3.16 +            printf("%d = %d\n", i, alpha_scancodes[i]);
    3.17          }
    3.18      }
    3.19      if (MapVirtualKey(VK_NUMPAD0, MAPVK_VK_TO_VSC) != keypad_scancodes[0]) {
    3.20 -printf("Fixing keypad scancode map!\nPlease send the following 10 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
    3.21 +        printf
    3.22 +            ("Fixing keypad scancode map!\nPlease send the following 10 lines of output to the SDL mailing list <sdl@libsdl.org>, including a description of your keyboard hardware.\n");
    3.23          for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
    3.24 -            keypad_scancodes[i] = MapVirtualKey(VK_NUMPAD0+i, MAPVK_VK_TO_VSC);
    3.25 -printf("%d = %d\n", i, keypad_scancodes[i]);
    3.26 +            keypad_scancodes[i] =
    3.27 +                MapVirtualKey(VK_NUMPAD0 + i, MAPVK_VK_TO_VSC);
    3.28 +            printf("%d = %d\n", i, keypad_scancodes[i]);
    3.29          }
    3.30      }
    3.31  
    3.32 @@ -99,7 +102,7 @@
    3.33  
    3.34          /* Alphabetic keys are handled specially, since Windows remaps them */
    3.35          if (i >= 'A' && i <= 'Z') {
    3.36 -            BYTE vsc = alpha_scancodes[i-'A'];
    3.37 +            BYTE vsc = alpha_scancodes[i - 'A'];
    3.38              keymap[scancode] = MapVirtualKey(vsc, MAPVK_VSC_TO_VK) + 0x20;
    3.39          } else {
    3.40              keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF);
     4.1 --- a/src/video/x11/SDL_x11events.c	Thu Mar 06 23:07:02 2008 +0000
     4.2 +++ b/src/video/x11/SDL_x11events.c	Fri Mar 07 17:20:37 2008 +0000
     4.3 @@ -51,15 +51,14 @@
     4.4      }
     4.5  
     4.6      data = NULL;
     4.7 -    if (videodata && 
     4.8 -        videodata->windowlist) {
     4.9 -      for (i = 0; i < videodata->numwindows; ++i) {
    4.10 -        if ((videodata->windowlist[i] != NULL) &&
    4.11 -            (videodata->windowlist[i]->window == xevent.xany.window)) {
    4.12 -          data = videodata->windowlist[i];
    4.13 -          break;
    4.14 +    if (videodata && videodata->windowlist) {
    4.15 +        for (i = 0; i < videodata->numwindows; ++i) {
    4.16 +            if ((videodata->windowlist[i] != NULL) &&
    4.17 +                (videodata->windowlist[i]->window == xevent.xany.window)) {
    4.18 +                data = videodata->windowlist[i];
    4.19 +                break;
    4.20 +            }
    4.21          }
    4.22 -      }
    4.23      }
    4.24      if (!data) {
    4.25          return;
     5.1 --- a/src/video/x11/SDL_x11opengl.c	Thu Mar 06 23:07:02 2008 +0000
     5.2 +++ b/src/video/x11/SDL_x11opengl.c	Fri Mar 07 17:20:37 2008 +0000
     5.3 @@ -281,19 +281,19 @@
     5.4  X11_GL_Initialize(_THIS)
     5.5  {
     5.6  
     5.7 -  if (X11_GL_InitializeMemory(_this) < 0) {
     5.8 -     return -1;
     5.9 -  }
    5.10 -  ++_this->gl_data->initialized;
    5.11 +    if (X11_GL_InitializeMemory(_this) < 0) {
    5.12 +        return -1;
    5.13 +    }
    5.14 +    ++_this->gl_data->initialized;
    5.15  
    5.16 -  if (X11_GL_LoadLibrary(_this, NULL) < 0) {
    5.17 -    return -1;
    5.18 -  }
    5.19 +    if (X11_GL_LoadLibrary(_this, NULL) < 0) {
    5.20 +        return -1;
    5.21 +    }
    5.22  
    5.23 -  /* Initialize extensions */
    5.24 -  X11_GL_InitExtensions(_this);
    5.25 +    /* Initialize extensions */
    5.26 +    X11_GL_InitExtensions(_this);
    5.27  
    5.28 -  return 0;
    5.29 +    return 0;
    5.30  }
    5.31  
    5.32  void
    5.33 @@ -523,6 +523,7 @@
    5.34      GLXContext glx_context = (GLXContext) context;
    5.35  
    5.36      _this->gl_data->glXDestroyContext(display, glx_context);
    5.37 +    XSync(display, False);
    5.38  }
    5.39  
    5.40  #endif /* SDL_VIDEO_OPENGL_GLX */
     6.1 --- a/src/video/x11/SDL_x11video.c	Thu Mar 06 23:07:02 2008 +0000
     6.2 +++ b/src/video/x11/SDL_x11video.c	Fri Mar 07 17:20:37 2008 +0000
     6.3 @@ -101,6 +101,7 @@
     6.4      if (data->display) {
     6.5          XCloseDisplay(data->display);
     6.6      }
     6.7 +    SDL_free(data->windowlist);
     6.8      SDL_free(device->driverdata);
     6.9      SDL_free(device);
    6.10  
     7.1 --- a/src/video/x11/SDL_x11video.h	Thu Mar 06 23:07:02 2008 +0000
     7.2 +++ b/src/video/x11/SDL_x11video.h	Fri Mar 07 17:20:37 2008 +0000
     7.3 @@ -67,6 +67,7 @@
     7.4      BOOL dpms_enabled;
     7.5      int numwindows;
     7.6      SDL_WindowData **windowlist;
     7.7 +    int windowlistlength;
     7.8      int mouse;
     7.9      int keyboard;
    7.10      Atom WM_DELETE_WINDOW;
     8.1 --- a/src/video/x11/SDL_x11window.c	Thu Mar 06 23:07:02 2008 +0000
     8.2 +++ b/src/video/x11/SDL_x11window.c	Fri Mar 07 17:20:37 2008 +0000
     8.3 @@ -34,8 +34,8 @@
     8.4      SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
     8.5      SDL_WindowData *data;
     8.6      int numwindows = videodata->numwindows;
     8.7 +    int windowlistlength = videodata->windowlistlength;
     8.8      SDL_WindowData **windowlist = videodata->windowlist;
     8.9 -    int i;
    8.10      int index;
    8.11  
    8.12      /* Allocate the window data */
    8.13 @@ -59,30 +59,24 @@
    8.14      data->videodata = videodata;
    8.15  
    8.16      /* Associate the data with the window */
    8.17 -    index = -1;
    8.18 -    if (windowlist) {
    8.19 -      for (i = 0; i < numwindows; ++i) {
    8.20 -        if (windowlist[i] == NULL) {
    8.21 -          index = i;
    8.22 -          break;
    8.23 +
    8.24 +    if (numwindows < windowlistlength) {
    8.25 +        windowlist[numwindows] = data;
    8.26 +        videodata->numwindows++;
    8.27 +    } else {
    8.28 +        windowlist =
    8.29 +            (SDL_WindowData **) SDL_realloc(windowlist,
    8.30 +                                            (numwindows +
    8.31 +                                             1) * sizeof(*windowlist));
    8.32 +        if (!windowlist) {
    8.33 +            SDL_OutOfMemory();
    8.34 +            SDL_free(data);
    8.35 +            return -1;
    8.36          }
    8.37 -      }
    8.38 -    }
    8.39 -
    8.40 -    if (index >= 0) {
    8.41 -      windowlist[index] = data;
    8.42 -    } else {
    8.43 -      windowlist =
    8.44 -      (SDL_WindowData **) SDL_realloc(windowlist,
    8.45 -                                      (numwindows + 1) * sizeof(*windowlist));
    8.46 -      if (!windowlist) {
    8.47 -        SDL_OutOfMemory();
    8.48 -        SDL_free(data);
    8.49 -        return -1;
    8.50 -      }
    8.51 -      windowlist[numwindows++] = data;
    8.52 -      videodata->numwindows = numwindows;
    8.53 -      videodata->windowlist = windowlist;
    8.54 +        windowlist[numwindows] = data;
    8.55 +        videodata->numwindows++;
    8.56 +        videodata->windowlistlength++;
    8.57 +        videodata->windowlist = windowlist;
    8.58      }
    8.59  
    8.60      /* Fill in the SDL window with the window data */
    8.61 @@ -494,7 +488,7 @@
    8.62  }
    8.63  
    8.64  int
    8.65 -X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
    8.66 +X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
    8.67  {
    8.68      Window w = (Window) data;
    8.69  
    8.70 @@ -665,13 +659,14 @@
    8.71          int i;
    8.72  
    8.73          if (windowlist) {
    8.74 -          for (i = 0; i < numwindows; ++i) {
    8.75 -            if (windowlist[i] && 
    8.76 -                (windowlist[i]->windowID == window->id)) {
    8.77 -              windowlist[i] = NULL;
    8.78 -              break;
    8.79 +            for (i = 0; i < numwindows; ++i) {
    8.80 +                if (windowlist[i] && (windowlist[i]->windowID == window->id)) {
    8.81 +                    windowlist[i] = windowlist[numwindows - 1];
    8.82 +                    windowlist[numwindows - 1] = NULL;
    8.83 +                    videodata->numwindows--;
    8.84 +                    break;
    8.85 +                }
    8.86              }
    8.87 -          }
    8.88          }
    8.89  #ifdef SDL_VIDEO_OPENGL_GLX
    8.90          if (window->flags & SDL_WINDOW_OPENGL) {