View previous topic :: View next topic |
Author |
Message |
r00k
Joined: 13 Nov 2004 Posts: 483
|
Posted: Thu Jun 24, 2010 7:36 pm Post subject: free(*ptr) problems with Windows7 |
|
|
Windows 7 keeps crashing if i use free(ptr) in some instances where in Win XP it doesnt
here's what i have replaced free with that works on both OS's but not sure if it's proper to use memset instead of free?
Code: |
if ((cls.download.error)||(success == FALSE))
{
Con_Printf ("Download Error: %s\n",cls.download.error);
Con_Printf ("\nThe required file '%s' could not be found at %s.\n", model_precache[i], url);
remove (download_tempname);
memset (download_tempname, 0, sizeof(download_tempname));
memset (download_finalname, 0, sizeof(download_finalname));
memset (url, 0, sizeof(url));
memset (name, 0, sizeof(name));
memset (folder, 0, sizeof(folder));
return;
}
|
|
|
Back to top |
|
 |
frag.machine

Joined: 25 Nov 2006 Posts: 728
|
Posted: Thu Jun 24, 2010 8:05 pm Post subject: |
|
|
memset () doesn't free the pointer, you're just clearing the memory it points - and not in a very legible way, since we cannot infer how much of the heap the variables passed as arguments to sizeof() are using. _________________ frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/ |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Thu Jun 24, 2010 8:34 pm Post subject: |
|
|
memory allocated with malloc must be freed within the same module that malloced it.
Failing that, you must ensure that the version of the CRT matches exactly.
Which it probably doesn't. _________________ What's a signature? |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 910
|
Posted: Thu Jun 24, 2010 10:25 pm Post subject: |
|
|
From looking at your code, you've got char download_tempname[MAX_QPATH] at the start of your loop. There's no need to free a static array, so the Windows 7 behaviour is actually correct, if a little less forgiving. _________________ DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines |
|
Back to top |
|
 |
r00k
Joined: 13 Nov 2004 Posts: 483
|
Posted: Fri Jun 25, 2010 3:42 am Post subject: |
|
|
Opps! was thinking they were static arrays, I guess i had revised and changed the variable declarations...
thanks to all for clarifying things  |
|
Back to top |
|
 |
|