Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uakari.primate.wisc.edu!ctrsol!ginosko!husc6!ogccse!blake!ano From: ano@blake.acs.washington.edu (John Michael Ano) Newsgroups: comp.windows.ms Subject: Memory Management & Data Structures Keywords: linked lists, moveable data segments Message-ID: <3033@blake.acs.washington.edu> Date: 31 Jul 89 17:26:35 GMT Reply-To: ano@blake.acs.washington.edu (John Michael Ano) Distribution: comp.windows.ms Organization: University of Washington, Dept. Psychology, Seattle Lines: 21 What is the best way to generate and maintain a linked list or B-tree in memory using Windows' memory management scheme? I'm working with relatively small structures (elements < 50) and they have a fairly long life-span. So I'm torn between allocating space in either the global or local data segment. For now I've decided that the structures are small enough to sit in the local DS, and now I'm wondering what the best way to allocate memory is. Is it wiser to allocate one big block and do lots of pointer arithmetic to maintain the list, or should I allocate one small block for each element and use the handles generated by LocalAlloc() to get pointers (with LocalLock()) to adjacent nodes? The drawback with the second method is that I have to lock and unlock each node to traverse the list. It seems awkward, but Petzold mentions that the GlobalLock and GlobalUnlock functions are fairly fast, and I assume the same applies to the local versions even though he says nothing about them. The allocated blocks are all allocated as LM_MOVEABLE so that Windows can move the blocks when memory gets scarce. How have other people dealt with data structure management under Windows? John Ano Dept. Psychology UW