Please Help On Freeing Custom Resources.
Hello,
I am having problem on freeing custom resources such as wave, midi and pcx.
The following is some of the code i am using
// Find the resource and load it into memory
if (((hResInfo = FindResource((struct HINSTANCE__ *)hinst, MAKEINTRESOURCE(resID), "WAVE")) != NULL) &&
((hResData = LoadResource((struct HINSTANCE__ *)hinst, hResInfo)) != NULL) && ((pRes = LockResource(hResData)) != NULL))
{
// If the resource was found, copy it to the
// memory location we allocate
dwSize = SizeofResource((struct HINSTANCE__ *)hinst, hResInfo);
lpMemory = malloc (dwSize);
memcpy (lpMemory, pRes, dwSize);
UnlockResource(hResData);
FreeResource(hResData);
Seems like i can''t free the resource memory since FreeResource is obsolete. Anyone out there have any idea?
November 07, 2000 01:55 PM
You don''t need to free them. In Win32 all that happens when you call LoadResource and LockResource is that part of your app gets paged in, if that.
If that didn''t make sense think of it this way. You don''t need to free the memory that your program (the actual code itself) is using right? You don''t need to free resources for the same reason.
You do of course need to free that stuff that you malloc''d.
-Mike
If that didn''t make sense think of it this way. You don''t need to free the memory that your program (the actual code itself) is using right? You don''t need to free resources for the same reason.
You do of course need to free that stuff that you malloc''d.
-Mike
Hmm... the problem is i can run my game in a 32mb ram PC by loading the pcx & midi & wave from files but when i try to load those things from the resource the game won''t run on 32mb ram PC but it runs on 64mb ram PC.
I think since i load the resource from my main game module and my game has only one module. The resources won''t be free until i quit the game.
I know there''s way to free predefined resource like DeleteObject to free bitmap resource. But how can i free those custom resource?
I think since i load the resource from my main game module and my game has only one module. The resources won''t be free until i quit the game.
I know there''s way to free predefined resource like DeleteObject to free bitmap resource. But how can i free those custom resource?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement