Article View: comp.os.ms-windows.programmer.tools
Article #529generic replacement for malloc and free using Global...?
From: Bill Whedon
Date: Thu, 12 Nov 1992 20:37
Date: Thu, 12 Nov 1992 20:37
41 lines
1615 bytes
1615 bytes
I wonder if anyone has a generic replacement for malloc and free which make
use of GlobalAlloc and GlobalFree? I did those up, but for some reason, the
memory thus allocated doesn't seem to be getting released properly, even
though I am careful to execute one free for each malloc. As an offshoot of
this, my memory slowly goes down in Windows until I terminate my app, at
which time it all appears to come back. Any ideas? Working procs? Please
email me and I will summarize, as I know of at least two other people who
want this stuff. I suspect there're more...
Thanks,
Bill Whedon whedon@netcom.com
P.S. My attempt follows (assume appropriate #include stuff):
void *mymalloc(size_t bytes)
{
void *p;
HANDLE h;
h = GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,(DWORD)bytes);
if (h)
p = (void *)GlobalLock(h);
else
p = NULL;
return p;
}
void myfree(void *p)
{
HANDLE h;
if (NULL != p)
{
h = (GLOBALHANDLE) LOWORD((LONG) p);
GlobalUnlock(h);
GlobalFree(h);
}
return;
}
--
-- If I ain't programmin' I ain't awake! --
Technical Details
Message-ID:
<1992Nov12.203727.11519@netcom.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!gumby!wupost!csus.edu!netcom.com!whedonShow Full Headers
Complete Article Headers
Newsgroups: comp.os.ms-windows.programmer.tools,comp.windows.ms.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!gumby!wupost!csus.edu!netcom.com!whedon From: whedon@netcom.com (Bill Whedon) Subject: generic replacement for malloc and free using Global...? Message-ID: <1992Nov12.203727.11519@netcom.com> Followup-To: poster Keywords: malloc free GlobalAlloc GlobalFree Organization: Netcom - Online Communication Services (408 241-9760 guest) Date: Thu, 12 Nov 1992 20:37:27 GMT Lines: 45