Article View: comp.windows.ms.programmer
Article #1980How to best represent a list in Windows?
From: fred jarvis
Date: Fri, 05 Apr 1991 09:25
Date: Fri, 05 Apr 1991 09:25
21 lines
1355 bytes
1355 bytes
I want to use a list structure in a Windows application.
Typically, something like
typedef struct {
datatype *data;
listnode *next;
} listnode;
would be used, with each node dynamically allocated.
But in Windows, you're supposed to use GlobalAlloc or LocalAlloc,
which return handles, not pointers, then using GlobalLock &
GlobalUnlock or LocalLock etc. to get the pointers for only as long
as you need access.
If listnode contains handles, rather than pointers, each time a
node is referenced, calls to GlobalLock & ..Unlock (or LocalLock...)
must be made, which seems inefficient to me.
I know LocalAlloc returns a pointer if called with the
LMEM_FIXED flag, but this is discouraged by the higher powers
(e.g. Petzold). So what is the best approach to take (besides
going back to DOS) ?
Fred Jarvis ferdie@coyote.datalog.com
Technical Details
Message-ID:
<e2BXZ1w163w@coyote.datalog.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!asuvax!noao!coyote!bbsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!asuvax!noao!coyote!bbs From: ferdie@coyote.datalog.com (fred jarvis) Newsgroups: comp.windows.ms.programmer Subject: How to best represent a list in Windows? Message-ID: <e2BXZ1w163w@coyote.datalog.com> Date: 5 Apr 91 09:25:46 GMT Sender: bbs@coyote.datalog.com (Waffle System) Organization: Datalog Consulting, Tucson, AZ Lines: 21