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:
Dabb 2000-07-19 17:58:19 +00:00
parent 260687d229
commit 1dd5b7ee10
1 changed files with 6 additions and 3 deletions

View File

@ -68,6 +68,8 @@ int old_windowed_mouse;
extern viddef_t vid; // global video state
unsigned short d_8to16table[256];
int modestate; // fixme: just to avoid cross-comp. errors - remove later
// The original defaults
//#define BASEWIDTH 320
//#define BASEHEIGHT 200
@ -141,7 +143,8 @@ void VID_Init (unsigned char *palette)
if (!(screen = SDL_SetVideoMode(vid.width, vid.height, 8, flags)))
Sys_Error("VID: Couldn't set video mode: %s\n", SDL_GetError());
VID_SetPalette(palette);
SDL_WM_SetCaption("sdlquake","sdlquake");
VID_SetCaption("sdlquakeworld");
// now know everything we need to know about the buffer
VGA_width = vid.conwidth = vid.width;
VGA_height = vid.conheight = vid.height;
@ -191,8 +194,8 @@ void VID_Update (vrect_t *rects)
++n;
// Second, copy them to SDL rectangles and update
if (!(sdlrects = (SDL_Rect *)alloca(n*sizeof(*sdlrects))))
Sys_Error("Out of memory");
if(!(sdlrects=(SDL_Rect *)calloc(1,n*sizeof(SDL_Rect))))
Sys_Error("Out of memory!");
i = 0;
for (rect = rects; rect; rect = rect->pnext)
{