Thread View: comp.os.ms-windows.programmer.tools
5 messages
5 total messages
Started by Shahrin Abdullah
Wed, 16 Dec 1992 06:26
How to implement a Linked List
Author: Shahrin Abdullah
Date: Wed, 16 Dec 1992 06:26
Date: Wed, 16 Dec 1992 06:26
9 lines
859 bytes
859 bytes
Hi there! Does anyone out there knows how to implement a linked list for Windows using MS C7. I know how to do it in C but in Windows it look tricky. I think I may need to use the global heap with the GMEM_MOVEABLE flag but I not too sure of going around doing it. Can anyone gave me some pointer, please. Any source code sample is also appreciated. Shahrin E-mail shah@iss.nus.sg
Re: How to implement a Linked List
Author: Chris Marriott
Date: Wed, 16 Dec 1992 19:03
Date: Wed, 16 Dec 1992 19:03
28 lines
1796 bytes
1796 bytes
In article <1992Dec16.062628.3410@nuscc.nus.sg> shah@cherry.NoSubdomain.NoDomain writes: >Hi there! >Does anyone out there knows how to implement a linked list for Windows using >MS C7. I know how to do it in C but in Windows it look tricky. I think I may >need to use the global heap with the GMEM_MOVEABLE flag but I not too sure >of going around doing it. Can anyone gave me some pointer, please. Any >source code sample is also appreciated. > >Shahrin >E-mail shah@iss.nus.sg > If you're using Microsoft C7, you can implement a linked list in Windows in exactly the same way you would for DOS - just use the standard run time library "malloc" function. If you use the large memory model (and there's no reason not to, any more), "malloc" gets mapped onto calls to a pretty good "sub-allocator". Chris -- -------------------------------------------------------------------------- | Chris Marriott | chris@chrism.demon.co.uk | | Warrington, UK | BIX: cmarriott | | (Still awaiting inspiration | CIX: cmarriott | | for a witty .sig .... ) | CompuServe: 100113,1140 | --------------------------------------------------------------------------
Re: How to implement a Linked List
Author: Shahrin Abdullah
Date: Thu, 17 Dec 1992 08:45
Date: Thu, 17 Dec 1992 08:45
31 lines
1868 bytes
1868 bytes
In article <724532588snz@chrism.demon.co.uk>, chris@chrism.demon.co.uk (Chris Marriott) writes:
|> In article <1992Dec16.062628.3410@nuscc.nus.sg> shah@cherry.NoSubdomain.NoDomain writes:
|>
|> >Hi there!
|> >Does anyone out there knows how to implement a linked list for Windows using
|> >MS C7. I know how to do it in C but in Windows it look tricky. I think I may
|> >need to use the global heap with the GMEM_MOVEABLE flag but I not too sure
|> >of going around doing it. Can anyone gave me some pointer, please. Any
|> >source code sample is also appreciated.
|> >
|> >Shahrin
|> >E-mail shah@iss.nus.sg
|> >
|>
|> If you're using Microsoft C7, you can implement a linked list in Windows
|> in exactly the same way you would for DOS - just use the standard run time
|> library "malloc" function. If you use the large memory model (and there's
|> no reason not to, any more), "malloc" gets mapped onto calls to a pretty
|> good "sub-allocator".
|>
|> Chris
|> --
The problem here is that malloc will map the memory allocation to the local
heap. Thus if the node dynamically grow too large the local heap won't be
able to handle that. So the question remain - how do U implement a linear
linked list using the Global Heap? Thanks Chris.
Cheers!
Shahrin
E-mail shah@iss.nus.sg
Re: How to implement a Linked List
Author: Tom W. Brown
Date: Thu, 17 Dec 1992 17:18
Date: Thu, 17 Dec 1992 17:18
30 lines
2135 bytes
2135 bytes
In article <1992Dec17.084558.9832@nuscc.nus.sg>, shah@cherry.NoSubdomain.NoDomain (Shahrin Abdullah) writes: |> In article <724532588snz@chrism.demon.co.uk>, chris@chrism.demon.co.uk (Chris Marriott) writes: |> |> |> |> If you're using Microsoft C7, you can implement a linked list in Windows |> |> in exactly the same way you would for DOS - just use the standard run time |> |> library "malloc" function. If you use the large memory model (and there's |> |> no reason not to, any more), "malloc" gets mapped onto calls to a pretty |> |> good "sub-allocator". |> |> |> |> The problem here is that malloc will map the memory allocation to the local |> heap. Thus if the node dynamically grow too large the local heap won't be |> able to handle that. So the question remain - how do U implement a linear |> linked list using the Global Heap? Thanks Chris. |> I can't adequately speak for Microsoft C7, but I know Borland 3.1 uses a sub-segment allocator with globally allocated memory if you compile in large model. I'd be very suprised if C7 did any different. Note that Chris specified large model in his reply -- this is definitely the key. However, if I'm wrong and C7 still uses the local heap for large model memory allocation then perhaps you should switch compilers :-) ---------------------------------------------------------------------------- Tom Brown | "She turned me into a newt... PE Nelson Systems | ... I got better" twbrown@pe-nelson.com | Monty Python and the Holy Grail ----------------------------------------------------------------------------
Re: How to implement a Linked List
Author: Greg Demichillie
Date: Thu, 17 Dec 1992 17:54
Date: Thu, 17 Dec 1992 17:54
44 lines
2260 bytes
2260 bytes
In article <1992Dec17.084558.9832@nuscc.nus.sg> shah@cherry.NoSubdomain.NoDomain (Shahrin Abdullah) writes: >In article <724532588snz@chrism.demon.co.uk>, chris@chrism.demon.co.uk (Chris Marriott) writes: >|> In article <1992Dec16.062628.3410@nuscc.nus.sg> shah@cherry.NoSubdomain.NoDomain writes: >|> >|> >Hi there! >|> >Does anyone out there knows how to implement a linked list for Windows using >|> >MS C7. I know how to do it in C but in Windows it look tricky. I think I may >|> >need to use the global heap with the GMEM_MOVEABLE flag but I not too sure >|> >of going around doing it. Can anyone gave me some pointer, please. Any >|> >source code sample is also appreciated. >|> > >|> >Shahrin >|> >E-mail shah@iss.nus.sg >|> > >|> >|> If you're using Microsoft C7, you can implement a linked list in Windows >|> in exactly the same way you would for DOS - just use the standard run time >|> library "malloc" function. If you use the large memory model (and there's >|> no reason not to, any more), "malloc" gets mapped onto calls to a pretty >|> good "sub-allocator". >|> >|> Chris >|> -- > >The problem here is that malloc will map the memory allocation to the local >heap. Thus if the node dynamically grow too large the local heap won't be >able to handle that. So the question remain - how do U implement a linear >linked list using the Global Heap? Thanks Chris. > This is incorrect. In versions prior to C7 malloc was implemented by allocating out of the local heap. This is no longer the case. In C7 malloc allocates larger blocks from the global heap and suballocates from them. You CAN just use malloc/free to do your linked list. -Greg -- Greg DeMichillie gregde@microsoft.com -- All opinions are mine, not Microsoft's --
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