Hacker News new | past | comments | ask | show | jobs | submit login

Too many evaluations of a. If you have snprintf, you probably have inline functions.

One day someone will do something like strncat(a += previous_delta, ...).




OPTION 1 (c):

  char* mystrncat(char *a, const char *b, size_t maxlen){
    snprintf(a + strlen(a), maxlen - strlen(a), "%s", b);
    return a;
  }
OPTION 2 (gccism):

   #define strncat(_a, b, maxlen) ({char* a = _a; snprintf(a + strlen(a), maxlen - strlen(a), "%s", b); _a;})




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: