structure function returns -- how?
Larry Campbell
campbell at maynard.BSW.COM
Sun Dec 7 09:33:59 AEST 1986
In article <131 at hcx1.UUCP> notes at 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 at maynard.bsw.com 120 Fulton Street, Boston MA 02109
uucp: {alliant,wjh12}!maynard!campbell +1 617 367 6846
ARPA: campbell%maynard.uucp at harvisr.harvard.edu MCI: LCAMPBELL
More information about the Comp.lang.c
mailing list