Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!rutgers!husc6!wjh12!maynard!campbell From: campbell@maynard.BSW.COM (Larry Campbell) Newsgroups: comp.lang.c Subject: Re: structure function returns -- how? Message-ID: <773@maynard.BSW.COM> Date: Sat, 6-Dec-86 18:33:59 EST Article-I.D.: maynard.773 Posted: Sat Dec 6 18:33:59 1986 Date-Received: Sun, 7-Dec-86 04:35:03 EST References: <131@hcx1.UUCP> Reply-To: campbell@maynard.UUCP (Larry Campbell) Organization: The Boston Software Works, Inc. Lines: 17 In article <131@hcx1.UUCP> notes@hcx1.UUCP writes: >Suppose a is declared as a structure and b is a function which >returns a structure. In the statement: > a = b () ; >when and how should the copying into a take place? The compiler on my system (which is pcc based) allocates static unnamed storage in b. It puts the result there and returns a pointer to the storage. The routine containing the assignment then copies the result into a, using the pointer returned by b. It seems to me that this is also signal-unsafe -- if a signal occurs just before the copy, and the signal handler calls b -- whammo. -- Larry Campbell The Boston Software Works, Inc. Internet: campbell@maynard.bsw.com 120 Fulton Street, Boston MA 02109 uucp: {alliant,wjh12}!maynard!campbell +1 617 367 6846 ARPA: campbell%maynard.uucp@harvisr.harvard.edu MCI: LCAMPBELL