Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!otter.hpl.hp.com!hpopd!richardh From: richardh@hpopd.pwd.hp.com (Richard Hancock) Newsgroups: comp.os.msdos.apps Subject: Re: Windows and pointers as parameters Message-ID: <38900002@hpopd.pwd.hp.com> Date: 26 Mar 91 12:34:31 GMT References: <1991Mar22.185504.3266@cs.uoregon.edu> Organization: The Vicuna Backlash Lines: 22 / hpopd:comp.os.msdos.apps / akm@geriatrix.cs.uoregon.edu (Anant Kartik Mithal) / 6:55 pm Mar 22, 1991 / Hi, > a question about pointers as function parameters. Given that windows > can move code/data around in memory (I believe that is correct), is > it okay (or is it not okay) to pass pointers as the arguments to a > function? What I want to do is to have a function set the values of a > couple of variables (boring sort of stuff), but I am not sure that I > can pass the variables through pointers to the setting function. eg: You shouldn't ASSUME that your DS will never change (though I suspect that in never will in protected mode). Therefore you shouldn't keep hold of a far pointer to a variable in your DS across any call which might cause your DS to move (eg. a GlobalAlloc() call). Having said that, I seem to remember that Windows locks your DS when it calls your WndProc. Summary : only pass near pointers; if you do eventually need them as far pointers simply cast them when you need to use them. Richard.