[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gcc and mint-libs PL46



What you wrote:
> |>>> fopen( NULL, "r" );
> |>>> 
> |>>> Results in a Bus Error.

> No, the library should not correct the users bugs.  If you added
> checks for NULL and other illegal input to all the lib functions it
> will be slow like a snail.  Add the checks to your program where it
> matters, most times it won't.

What?!?  So, I should do this:

if( fname ) {
	fp = fopen( fname, "r" );
	if( !fp ) {
		fprintf( stderr, "oops.  No filename here at line %d.\n", __LINE__ );
		exit( ENOENT );
	}
} else {
	fprintf( stderr, "oops, didn't pass a filename.\n" );
}

That's ridiculous.  The librarys are supposed to do this sort of thing
for you, so _you_ don't have to do it every time you fopen.  It's
certainly not going to slow you down to a crawl... how much
time-critical code have you written that depends on the speed of fopen?

-- 
----------========================================================----------
Chris Herborth, R&D Technical Writer       Arcane  Dragon     chrish@qnx.com
QNX Software Systems, Ltd.                  -==(UDIC)==-         |||  JAGUAR
http://quest.jpl.nasa.gov/Info-ZIP/people/cjh/chris.html        / | \ 64-bit