Thread View: comp.os.ms-windows.programmer.tools
1 messages
1 total messages
Started by Bill Whedon
Thu, 12 Nov 1992 20:37
generic replacement for malloc and free using Global...?
Author: 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! --
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads