home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / mswindo / programm / tools / 1444 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.0 KB  |  49 lines

  1. Newsgroups: comp.os.ms-windows.programmer.tools,comp.windows.ms.programmer
  2. Path: sparky!uunet!wupost!uwm.edu!cs.utexas.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!riacs!speclab.cr.usgs.gov!ngorelic
  3. From: ngorelic@speclab.cr.usgs.gov.cr.usgs.gov (Noel S. Gorelick)
  4. Subject: Re: Replacement for malloc using GlobalAlloc
  5. Message-ID: <1992Nov17.020804.20835@riacs.edu>
  6. Sender: news@riacs.edu
  7. Reply-To: ngorelic@speclab.cr.usgs.gov
  8. Organization: MercWorks, Denver
  9. X-Newsreader: TIN [version 1.1 PL6]
  10. References: <1992Nov14.092011.29891@netcom.com>
  11. Date: Tue, 17 Nov 92 02:08:04 GMT
  12. Lines: 35
  13.  
  14. Bill Whedon (whedon@netcom.com) wrote:
  15. > Here's the summary I promised.  The answers I got were mixed.  Advice to
  16. > keep using malloc, advice to use _fmalloc, neither of which solved the
  17. > original problem (corruption of a linked list).  The most useful was from
  18. > raymondc@microsoft.com, who sent me a fix for the myfree() routine which
  19. > stopped my memory leak.  Both routines follow this note.  
  20. >
  21. > void *mymalloc(size_t bytes)
  22. > ...
  23. >    h = GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT,(DWORD)bytes);
  24. > ...
  25. > void myfree(void *p)
  26. > ...
  27. >       h = (GLOBALHANDLE)SELECTOROF((LPVOID)p);
  28. > ...
  29.  
  30. Question 1)   What is SELECTOROF()?  I am assuming it is the equivalent of
  31.               GlobalHandle()?
  32.  
  33. Question 2)   What do you do about running out of HANDLES?  It has been my
  34.               expereince, and I have had it confirmed by a few other 
  35.               programmers, that you only get to allocate about 8000 handles,
  36.           using GlobalAlloc, before you start getting incoherent results...
  37.           Is there any way around this, short of allocating large blocks 
  38.           and doing your own memory management?
  39.  
  40.           And if there isn't, does someone have a set of routines to do
  41.           this allocation yet?
  42.  
  43. Noel
  44. --
  45. "You want it should sing too?"   | /*  Yeah we got dogs and Valvoline
  46.   ngorelic@speclab.cr.usgs.gov   |     Its a pretty damn good time.    */
  47. "Life is pain. Anyone that tells you different is trying to sell you something"
  48.