Path: utzoo!mnetor!uunet!husc6!tut.cis.ohio-state.edu!morganucodon.cis.ohio-state.edu!paul From: paul@morganucodon.cis.ohio-state.edu (Paul Placeway) Newsgroups: comp.sys.mac.programmer Subject: Re: Pointer arithmetic in C w/ or w/o locked handles Message-ID: <10897@tut.cis.ohio-state.edu> Date: 18 Apr 88 19:43:37 GMT References: <1988Apr15.125337.100@mntgfx.mentor.com> Sender: news@tut.cis.ohio-state.edu Organization: The Ohio State University Dept of Computer and Information Science Lines: 24 Keywords: pointer C arithmetic handles In article <1988Apr15.125337.100@mntgfx.mentor.com> tomc@mntgfx.mentor.com (Tom Carstensen) writes: < ... < HUnlock(hdl); < length = (long) (ptr - *hdl); < ... < If I move the length calculation before I unlock the < handle, then length becomes 8, and I'm ok. I would be _really_ supprised if something like this continued to work correctly (assuming that it does allready; which it seems not to). Personally, I wouldn't HUnlock the handle until you are done with it (ie. _after_ the length calculation). It is possible (although currently unlikely) that the block that the handle points to could be moved between the HUnlock and the last derefrence. Race conditions like this should be avoided -- they create bugs without adding any benifit. -- Paul Placeway -=- Existence is beyond the power of words To define: Terms may be used But are none of them absolute.