Path: 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: Date: 5 Apr 91 09:25:46 GMT Sender: bbs@coyote.datalog.com (Waffle System) Organization: Datalog Consulting, Tucson, AZ Lines: 21 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