Unix V.4 gettxt() return type

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Sep 14 04:36:21 AEST 1990


In article <145 at comtst.UUCP> mdv at 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.



More information about the Comp.unix.questions mailing list