🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #620

Re: Linked list in Windows

#620
From: Joel Spolsky
Date: Sun, 11 Nov 1990 20:40
22 lines
1765 bytes
In article <17167@shlump.nac.dec.com> nadkarni@ashok.dec.com (Ashok P. Nadkarni) writes:
>I am porting an application to Windows 3.0 that makes extensive use
>of linked lists. Storage needs are sufficiently large that I have
>to use global memory. I know just enough about Windows programming that
>I realize it is Bad Thing to leave memory locked. However, unlocking means
>that all the links pointing to the prev/next list elements are garbage
>every time Windows moves memory around. Is there a solution to this problem?


Here are two possibilities: either keep handles, not pointers in the
linked list, and lock them when you need them. However this does make
traversing the linked list a bit messy, if you do that a lot, locking
and unlocking as you move along. (sadness). 

The other possibility; if your program is only going to be run on
386's (in enhanced mode), it doesn't hurt to keep everything locked
down, because the hardware can still move things about without the far
pointers changing. I ported a large system to windows this way; it is
enough to replace malloc(x) with GlocalLock(GlobalAlloc(GMEM_MOVEABLE,x));

Joel Spolsky
spolsky@cs.yale.edu                                     Silence = Death
Technical Details
Message-ID: <27221@cs.yale.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!quasi-eli!cs.yale.edu!spolsky-joel
References: <17167@shlump.nac.dec.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!quasi-eli!cs.yale.edu!spolsky-joel
From: spolsky-joel@cs.yale.edu (Joel Spolsky)
Newsgroups: comp.windows.ms.programmer
Subject: Re: Linked list in Windows
Message-ID: <27221@cs.yale.edu>
Date: 11 Nov 90 20:40:32 GMT
References: <17167@shlump.nac.dec.com>
Sender: news@cs.yale.edu
Organization: Yale University Computer Science Dept., New Haven, CT 06520-2158
Lines: 22
Nntp-Posting-Host: zoo-gw.cs.yale.edu
Originator: spolsky@suned.CS.Yale.Edu