From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <86c8258a9fa258f8ba09aaef4ae7fa79.axp-list@archive.invalid> X-Archive-Original-Message-ID: <9702202259.ZM1361@davros.bwh.com> Date: Thu, 20 Feb 1997 22:59:49 -0600 From: Bryan W. Headley Subject: Re: fclose() (fwd) In-Reply-To: On Feb 18, 11:14am, Jerry Feldman wrote: > Subject: Re: fclose() (fwd) > > > I just checked and Linux and Digital Unix both do the same thing. Heres > > the program: > Not quite. On Digital Unix, I change %x to %lx. Pointers are 64 bits. > > #include > > #include > > > > int main(void) > > { > > int i; > > for(i=0; i<3; i++) { > > FILE *f = fopen("/dev/null","r"); > > printf("f = %lx\n", f); > > fclose(f); > > } > > return 0; > > } > > > > and here is the Digital Unix output: > sauron:assem [1528%] a.out > f = 3ffc0080348 > f = 3ffc0080380 > f = 3ffc0080380 > -- That's incredibly stupid. Is this a /dev/null trick ("read all you want, there's plenty of nothing for you"). Let's say I open /etc/passwd three times and start reading records from each (but not necessarily synchronized; f1 reads 20 bytes, f2 reads 30 bytes, f3 lseeks to the end of file - 50 bytes) There's no way these three pointers can be to the same address; there's no excuse for fclose()ing one automagically closing another (esp. if you fclose it twice, because, well, you're a fool, but you have a license to be a fool on the wall) -- Bryan W. Headley Home: bheadley@interaccess.com 211 East Pineview Drive Office: bwh@abnamro.com Round Lake Park, IL 60073 Phone: 847 740-1446 -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com