Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
more valgrind errors fixed. Plus I ran make indent which changed a fe…
Browse files Browse the repository at this point in the history
…w files.
  • Loading branch information
pendletonrc committed Mar 7, 2008
1 parent dffd962 commit 2935ccc
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 59 deletions.
5 changes: 5 additions & 0 deletions src/video/SDL_video.c
Expand Up @@ -2190,6 +2190,11 @@ SDL_VideoQuit(void)
display->windows = NULL;
}
display->num_windows = 0;
if (display->render_drivers) {
SDL_free(display->render_drivers);
display->render_drivers = NULL;
}
display->num_render_drivers = 0;
}
_this->VideoQuit(_this);

Expand Down
6 changes: 3 additions & 3 deletions src/video/win32/SDL_win32events.c
Expand Up @@ -36,7 +36,7 @@
#define REPEATED_KEYMASK (1<<30)
#define EXTENDED_KEYMASK (1<<24)

#define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */
#define VK_ENTER 10 /* Keypad Enter ... no VKEY defined? */

/* Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... */
#ifndef WM_XBUTTONDOWN
Expand All @@ -53,7 +53,7 @@ static WPARAM
RemapVKEY(WPARAM wParam, LPARAM lParam)
{
int i;
BYTE scancode = (BYTE)((lParam >> 16) & 0xFF);
BYTE scancode = (BYTE) ((lParam >> 16) & 0xFF);

/* Windows remaps alphabetic keys based on current layout.
We try to provide USB scancodes, so undo this mapping.
Expand All @@ -72,7 +72,7 @@ RemapVKEY(WPARAM wParam, LPARAM lParam)
/* Keypad keys are a little trickier, we always scan for them. */
for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
if (scancode == keypad_scancodes[i]) {
wParam = VK_NUMPAD0+i;
wParam = VK_NUMPAD0 + i;
break;
}
}
Expand Down
19 changes: 11 additions & 8 deletions src/video/win32/SDL_win32keyboard.c
Expand Up @@ -53,18 +53,21 @@ WIN_InitKeyboard(_THIS)
int i;

/* Make sure the alpha scancodes are correct. T isn't usually remapped */
if (MapVirtualKey('T', MAPVK_VK_TO_VSC) != alpha_scancodes['T'-'A']) {
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");
if (MapVirtualKey('T', MAPVK_VK_TO_VSC) != alpha_scancodes['T' - 'A']) {
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");
for (i = 0; i < SDL_arraysize(alpha_scancodes); ++i) {
alpha_scancodes[i] = MapVirtualKey('A'+i, MAPVK_VK_TO_VSC);
printf("%d = %d\n", i, alpha_scancodes[i]);
alpha_scancodes[i] = MapVirtualKey('A' + i, MAPVK_VK_TO_VSC);
printf("%d = %d\n", i, alpha_scancodes[i]);
}
}
if (MapVirtualKey(VK_NUMPAD0, MAPVK_VK_TO_VSC) != keypad_scancodes[0]) {
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");
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");
for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
keypad_scancodes[i] = MapVirtualKey(VK_NUMPAD0+i, MAPVK_VK_TO_VSC);
printf("%d = %d\n", i, keypad_scancodes[i]);
keypad_scancodes[i] =
MapVirtualKey(VK_NUMPAD0 + i, MAPVK_VK_TO_VSC);
printf("%d = %d\n", i, keypad_scancodes[i]);
}
}

Expand Down Expand Up @@ -99,7 +102,7 @@ WIN_UpdateKeymap(int keyboard)

/* Alphabetic keys are handled specially, since Windows remaps them */
if (i >= 'A' && i <= 'Z') {
BYTE vsc = alpha_scancodes[i-'A'];
BYTE vsc = alpha_scancodes[i - 'A'];
keymap[scancode] = MapVirtualKey(vsc, MAPVK_VSC_TO_VK) + 0x20;
} else {
keymap[scancode] = (MapVirtualKey(i, MAPVK_VK_TO_CHAR) & 0x7FFF);
Expand Down
15 changes: 7 additions & 8 deletions src/video/x11/SDL_x11events.c
Expand Up @@ -51,15 +51,14 @@ X11_DispatchEvent(_THIS)
}

data = NULL;
if (videodata &&
videodata->windowlist) {
for (i = 0; i < videodata->numwindows; ++i) {
if ((videodata->windowlist[i] != NULL) &&
(videodata->windowlist[i]->window == xevent.xany.window)) {
data = videodata->windowlist[i];
break;
if (videodata && videodata->windowlist) {
for (i = 0; i < videodata->numwindows; ++i) {
if ((videodata->windowlist[i] != NULL) &&
(videodata->windowlist[i]->window == xevent.xany.window)) {
data = videodata->windowlist[i];
break;
}
}
}
}
if (!data) {
return;
Expand Down
21 changes: 11 additions & 10 deletions src/video/x11/SDL_x11opengl.c
Expand Up @@ -281,19 +281,19 @@ int
X11_GL_Initialize(_THIS)
{

if (X11_GL_InitializeMemory(_this) < 0) {
return -1;
}
++_this->gl_data->initialized;
if (X11_GL_InitializeMemory(_this) < 0) {
return -1;
}
++_this->gl_data->initialized;

if (X11_GL_LoadLibrary(_this, NULL) < 0) {
return -1;
}
if (X11_GL_LoadLibrary(_this, NULL) < 0) {
return -1;
}

/* Initialize extensions */
X11_GL_InitExtensions(_this);
/* Initialize extensions */
X11_GL_InitExtensions(_this);

return 0;
return 0;
}

void
Expand Down Expand Up @@ -523,6 +523,7 @@ X11_GL_DeleteContext(_THIS, SDL_GLContext context)
GLXContext glx_context = (GLXContext) context;

_this->gl_data->glXDestroyContext(display, glx_context);
XSync(display, False);
}

#endif /* SDL_VIDEO_OPENGL_GLX */
Expand Down
1 change: 1 addition & 0 deletions src/video/x11/SDL_x11video.c
Expand Up @@ -101,6 +101,7 @@ X11_DeleteDevice(SDL_VideoDevice * device)
if (data->display) {
XCloseDisplay(data->display);
}
SDL_free(data->windowlist);
SDL_free(device->driverdata);
SDL_free(device);

Expand Down
1 change: 1 addition & 0 deletions src/video/x11/SDL_x11video.h
Expand Up @@ -67,6 +67,7 @@ typedef struct SDL_VideoData
BOOL dpms_enabled;
int numwindows;
SDL_WindowData **windowlist;
int windowlistlength;
int mouse;
int keyboard;
Atom WM_DELETE_WINDOW;
Expand Down
55 changes: 25 additions & 30 deletions src/video/x11/SDL_x11window.c
Expand Up @@ -34,8 +34,8 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *data;
int numwindows = videodata->numwindows;
int windowlistlength = videodata->windowlistlength;
SDL_WindowData **windowlist = videodata->windowlist;
int i;
int index;

/* Allocate the window data */
Expand All @@ -59,30 +59,24 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
data->videodata = videodata;

/* Associate the data with the window */
index = -1;
if (windowlist) {
for (i = 0; i < numwindows; ++i) {
if (windowlist[i] == NULL) {
index = i;
break;
}
}
}

if (index >= 0) {
windowlist[index] = data;
if (numwindows < windowlistlength) {
windowlist[numwindows] = data;
videodata->numwindows++;
} else {
windowlist =
(SDL_WindowData **) SDL_realloc(windowlist,
(numwindows + 1) * sizeof(*windowlist));
if (!windowlist) {
SDL_OutOfMemory();
SDL_free(data);
return -1;
}
windowlist[numwindows++] = data;
videodata->numwindows = numwindows;
videodata->windowlist = windowlist;
windowlist =
(SDL_WindowData **) SDL_realloc(windowlist,
(numwindows +
1) * sizeof(*windowlist));
if (!windowlist) {
SDL_OutOfMemory();
SDL_free(data);
return -1;
}
windowlist[numwindows] = data;
videodata->numwindows++;
videodata->windowlistlength++;
videodata->windowlist = windowlist;
}

/* Fill in the SDL window with the window data */
Expand Down Expand Up @@ -494,7 +488,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
}

int
X11_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
{
Window w = (Window) data;

Expand Down Expand Up @@ -665,13 +659,14 @@ X11_DestroyWindow(_THIS, SDL_Window * window)
int i;

if (windowlist) {
for (i = 0; i < numwindows; ++i) {
if (windowlist[i] &&
(windowlist[i]->windowID == window->id)) {
windowlist[i] = NULL;
break;
for (i = 0; i < numwindows; ++i) {
if (windowlist[i] && (windowlist[i]->windowID == window->id)) {
windowlist[i] = windowlist[numwindows - 1];
windowlist[numwindows - 1] = NULL;
videodata->numwindows--;
break;
}
}
}
}
#ifdef SDL_VIDEO_OPENGL_GLX
if (window->flags & SDL_WINDOW_OPENGL) {
Expand Down

0 comments on commit 2935ccc

Please sign in to comment.