home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / mswindo / programm / tools / 1761 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.2 KB  |  55 lines

  1. Newsgroups: comp.os.ms-windows.programmer.tools
  2. Path: sparky!uunet!microsoft!hexnut!gregde
  3. From: gregde@microsoft.com (Greg Demichillie)
  4. Subject: Re: How to implement a Linked List 
  5. Message-ID: <1992Dec17.175420.2457@microsoft.com>
  6. Date: 17 Dec 92 17:54:20 GMT
  7. Organization: Microsoft Corporation
  8. References: <1992Dec16.062628.3410@nuscc.nus.sg> <724532588snz@chrism.demon.co.uk> <1992Dec17.084558.9832@nuscc.nus.sg>
  9. Lines: 43
  10.  
  11. In article <1992Dec17.084558.9832@nuscc.nus.sg> shah@cherry.NoSubdomain.NoDomain (Shahrin Abdullah) writes:
  12. >In article <724532588snz@chrism.demon.co.uk>, chris@chrism.demon.co.uk (Chris Marriott) writes:
  13. >|> In article <1992Dec16.062628.3410@nuscc.nus.sg> shah@cherry.NoSubdomain.NoDomain writes:
  14. >|> 
  15. >|> >Hi there!
  16. >|> >Does anyone out there knows how to implement a linked list for Windows using
  17. >|> >MS C7. I know how to do it in C but in Windows it look tricky. I think I may
  18. >|> >need to use the global heap with the GMEM_MOVEABLE flag but I not too sure
  19. >|> >of going around  doing it. Can anyone gave me some pointer, please. Any 
  20. >|> >source code sample is also appreciated. 
  21. >|> >
  22. >|> >Shahrin 
  23. >|> >E-mail shah@iss.nus.sg
  24. >|> >
  25. >|> 
  26. >|> If you're using Microsoft C7, you can implement a linked list in Windows
  27. >|> in exactly the same way you would for DOS - just use the standard run time
  28. >|> library "malloc" function.  If you use the large memory model (and there's
  29. >|> no reason not to, any more), "malloc" gets mapped onto calls to a pretty
  30. >|> good "sub-allocator".
  31. >|> 
  32. >|> Chris
  33. >|> -- 
  34. >The problem here is that malloc will map the memory allocation to the local
  35. >heap. Thus if the node dynamically grow too large the local heap won't be
  36. >able to handle that. So the question remain - how do U implement a linear 
  37. >linked list using the Global Heap? Thanks Chris.
  38. >
  39.  
  40. This is incorrect.  In versions prior to C7 malloc was implemented by 
  41. allocating out of the local heap.  This is no longer the case.  In C7
  42. malloc allocates larger blocks from the global heap and suballocates from
  43. them.
  44.  
  45. You CAN just use malloc/free to do your linked list.
  46.  
  47.  
  48. -Greg
  49.  
  50.  
  51. -- 
  52. Greg DeMichillie          
  53. gregde@microsoft.com      -- All opinions are mine, not Microsoft's -- 
  54.