Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.unix.questions Subject: Re: Unix V.4 gettxt() return type Keywords: Unix V.4, gettxt Message-ID: <13846@smoke.BRL.MIL> Date: 13 Sep 90 18:36:21 GMT References: <145@comtst.UUCP> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 18 In article <145@comtst.UUCP> mdv@comtst.domain.com (Mike Verstegen) writes: >Does the return value "point to static data which is overwritten with each >call" or is the point good for multiple uses? Without even looking at the code, you can pretty much figure out what the answer must be. There are essentially three possibilities for the implementation of gettxt() in this regard: (A) return pointer to dynamically allocated space containing a copy of the relevant message (B) return pointer to static buffer that is reused across calls (C) return pointer to member of array or structure containing all messages Alternative (C) is unlikely, as it would force the entire set of messages to be hard-wired into the library. Alternative (A) is unlikely, as it would result in gradually losing more and more dynamic memory as gettxt() is invoked multiple times. So I would simply assume that (B) is the probable answer. Since that is the worst case anyway (from your point of view), it seems like a good assumption to make.