aryeh@cash.uucp (the over worked C something or another) (10/01/90)
From tmpname(3) or sunos4.1: > char *tmpnam (s) > char *s; > tmpnam() always generates a file name using the path-prefix > defined as P_tmpdir in the <stdio.h> header file. If s is > NULL, tmpnam() leaves its result in an internal static area > and returns a pointer to that area. The next call to > tmpnam() will destroy the contents of the area. If _s is not > NULL, it is assumed to be the address of an array of at > least L_tmpnam bytes, where L_tmpnam is a constant defined > in <stdio.h>; tmpnam() places its result in that array and > returns s. I am to assume if I call tmpname once with a NULL arg and then call it again with a pointer to char s[...] that it will nuke the old L_tmpnam? Sun Release 4.0 Last change: 1 February 1988 2 -- Aryeh Friedman aryeh@cash.ucsc.edu or "ain't bug hunts the funnest" tsource@watnxt2.ucr.edu
rmj@tcom.stc.co.uk (The Beardless Wonder) (10/02/90)
In article <7372@darkstar.ucsc.edu> aryeh@cash.uucp (the over worked C something or another) writes: >From tmpname(3) or sunos4.1: >> char *tmpnam (s) >> char *s; >> [Rest of manual page] > >I am to assume if I call tmpname once with a NULL arg and then call it >again with a pointer to char s[...] that it will nuke the old L_tmpnam? No, but it will nuke the name string that the first call to tmpname produced (unless you have strcopied it somewhere safe first). L_tmpnam is the constant defining the minimum length that your char s[] should be. Thus an array declared as char s[L_tmpnam]; would be big enough to safely use as an argument to tmpname. As a constant, L_tmpname is not subject to nuking (well, you know what I mean). -- * Windsinger * "But soft, what light through yonder * rmj@islay.tcom.stc.co.uk * airlock breaks?" * rmj@tcom.stc.co.uk * --RETURN TO THE FORBIDDEN PLANET * rmj10@phx.cam.ac.uk * You've gotta be cruel to be Khund!