free(*ptr) problems with Windows7
Moderator: InsideQC Admins
5 posts
• Page 1 of 1
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?
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: Select all
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;
}
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
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.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
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.
Failing that, you must ensure that the version of the CRT matches exactly.
Which it probably doesn't.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
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.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest