strcat+strcat+strcat == baaad"
Dimitrie O. Paun
dpaun at rogers.com
Fri Dec 6 09:50:40 CST 2002
On December 5, 2002 11:16 am, Alexandre Julliard wrote:
> It's the kind of thinking that leads to having an exception
> handler inside strlen() like Windows does. It's just plain wrong.
<nod/>. This is generally true for other things as well:
1. Many places in our code where we have invariant like
pointer p is never NULL, yet we always have:
if (!p) return NULL; /* or whatever error condition */
Such a check is harmful (hides bugs), slow (useless
runtime check), bloat (more generated code),
ugly (clutters the code), at the very least. Just
Don't Do It (TM) -- let the code crash.
2. ZeroMemory when we don't need to, when we pass struct
internally, yet same functions can be called externally
with no guarantee that the struct has unused field
zeroed out.
3. In general, we have all sort of 'defensive programming'
checks for invariants. Problem is, we never going to
catch bugs in this area this way. Just use assert()
if you feel a check is needed.
In short, this defensive programming crap is just that: crap.
--
Dimi.
More information about the wine-devel
mailing list