Wabewalker ([info]wabewalker) wrote,
@ 2007-11-20 13:08:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Current location:2821 Mission College Blvd, Santa Clara, CA
Current mood: crying
Entry tags:technology, work

This is why you’re not allowed to have nice things

While doing maintenance, I found the following atrocity:

inline void fast_strncpy(char *dest, const char *src, int nbytes) {
  if (nbytes <= 10) {
    switch (nbytes) {
      case 1:
        dest[0] = '\0';
        break;
      case 2:
        dest[0] = src[0];
        dest[1] = '\0';
        break;
      case 3:
        dest[0] = src[0];
        dest[1] = src[1];
        dest[2] = '\0';
        break;
      case 4:
        dest[0] = src[0];
        dest[1] = src[1];
        dest[2] = src[2];
        dest[3] = '\0';
        break;
        // AND SO ON FOR AN OBSCENE NUMBER OF CASES...
  }
  else {
    memcpy(dest, src, nbytes - 1);
    dest[nbytes] = '\0'; // WHAT’S WRONG HERE, KIDS?
  }
}

“Why does our performance suck compared to the competitors?”

Because maybe, just maybe, your engineers can’t program worth crap?



Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…