[LCP]wrapper around strcmp

sasidhar p psasidhar at hotmail.com
Wed May 22 22:22:05 UTC 2002


Hi all,
  I am interested in a wrapper around 'strcmp' to avoid problems that might 
occur when one of the agruments to 'strcmp' are NULL. I would like your 
opinions/advice on the following two approaches in terms of efficiency as I 
plan keep them in my library routines.

1)  inline bool streq1(const char*a, const char*b) {
      if (!a || !b || a[0] != b[0])
        return false;
      return !strcmp(a,b);
    }


2)  inline bool streq2(const char*a, const char*b) {
      assert(a != NULL);
      assert(b != NULL);
      return !strcmp(a,b);
    }

Thanks,
Sasi.



_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com





More information about the linuxCprogramming mailing list