mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-02-02 04:32:24 +00:00
Changed alloca -> calloc to fix crash bug.
Also added modestate (will be removed). btw, something to remember about ALLOCA: "If the calling function does not contain any references to local variables in the stack, the stack will not be restored correctly when the function exits, resulting in a program crash. "
This commit is contained in:
parent
260687d229
commit
1dd5b7ee10
1 changed files with 6 additions and 3 deletions
|
@ -68,6 +68,8 @@ int old_windowed_mouse;
|
||||||
extern viddef_t vid; // global video state
|
extern viddef_t vid; // global video state
|
||||||
unsigned short d_8to16table[256];
|
unsigned short d_8to16table[256];
|
||||||
|
|
||||||
|
int modestate; // fixme: just to avoid cross-comp. errors - remove later
|
||||||
|
|
||||||
// The original defaults
|
// The original defaults
|
||||||
//#define BASEWIDTH 320
|
//#define BASEWIDTH 320
|
||||||
//#define BASEHEIGHT 200
|
//#define BASEHEIGHT 200
|
||||||
|
@ -141,7 +143,8 @@ void VID_Init (unsigned char *palette)
|
||||||
if (!(screen = SDL_SetVideoMode(vid.width, vid.height, 8, flags)))
|
if (!(screen = SDL_SetVideoMode(vid.width, vid.height, 8, flags)))
|
||||||
Sys_Error("VID: Couldn't set video mode: %s\n", SDL_GetError());
|
Sys_Error("VID: Couldn't set video mode: %s\n", SDL_GetError());
|
||||||
VID_SetPalette(palette);
|
VID_SetPalette(palette);
|
||||||
SDL_WM_SetCaption("sdlquake","sdlquake");
|
VID_SetCaption("sdlquakeworld");
|
||||||
|
|
||||||
// now know everything we need to know about the buffer
|
// now know everything we need to know about the buffer
|
||||||
VGA_width = vid.conwidth = vid.width;
|
VGA_width = vid.conwidth = vid.width;
|
||||||
VGA_height = vid.conheight = vid.height;
|
VGA_height = vid.conheight = vid.height;
|
||||||
|
@ -191,8 +194,8 @@ void VID_Update (vrect_t *rects)
|
||||||
++n;
|
++n;
|
||||||
|
|
||||||
// Second, copy them to SDL rectangles and update
|
// Second, copy them to SDL rectangles and update
|
||||||
if (!(sdlrects = (SDL_Rect *)alloca(n*sizeof(*sdlrects))))
|
if(!(sdlrects=(SDL_Rect *)calloc(1,n*sizeof(SDL_Rect))))
|
||||||
Sys_Error("Out of memory");
|
Sys_Error("Out of memory!");
|
||||||
i = 0;
|
i = 0;
|
||||||
for (rect = rects; rect; rect = rect->pnext)
|
for (rect = rects; rect; rect = rect->pnext)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue