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

Re: gcc and mint-libs PL46



> Amen. How much larger would a program be if the libs did the check for
> NULL (once) instead of the program (many times, potentially)?

This is ludicrous; there are many ways a pointer can be invalid without
being zero, and the library cannot even test if it points to a valid
page! Putting such a test in a library would _not_ make it more robust,
it would only make it slower. Let me state it again: there is _no way_
to determine if a pointer points to a valid memory area. And even if it
were possible, you'd still have the problem of functions expecting a
null-terminated string, if a '\0' can't be found on this page and the
next page is unmapped.

Only the operating system can, and _must_, check its arguments. This
adds some overhead of course, but you can't avoid it unless you can
afford a system panic.

Thierry.