Back to index

glibc  2.9
Functions
wmemcmp.c File Reference
#include <wchar.h>

Go to the source code of this file.

Functions

int wmemcmp (wchar_t *s1, const wchar_t *s2, size_t n) const

Function Documentation

int wmemcmp ( wchar_t *  s1,
const wchar_t *  s2,
size_t  n 
) const

Definition at line 24 of file wmemcmp.c.

{
  register wint_t c1;
  register wint_t c2;

  while (n >= 4)
    {
      c1 = (wint_t) s1[0];
      c2 = (wint_t) s2[0];
      if (c1 - c2 != 0)
       return c1 - c2;
      c1 = (wint_t) s1[1];
      c2 = (wint_t) s2[1];
      if (c1 - c2 != 0)
       return c1 - c2;
      c1 = (wint_t) s1[2];
      c2 = (wint_t) s2[2];
      if (c1 - c2 != 0)
       return c1 - c2;
      c1 = (wint_t) s1[3];
      c2 = (wint_t) s2[3];
      if (c1 - c2 != 0)
       return c1 - c2;
      s1 += 4;
      s2 += 4;
      n -= 4;
    }

  if (n > 0)
    {
      c1 = (wint_t) s1[0];
      c2 = (wint_t) s2[0];
      if (c1 - c2 != 0)
       return c1 - c2;
      ++s1;
      ++s2;
      --n;
    }
  if (n > 0)
    {
      c1 = (wint_t) s1[0];
      c2 = (wint_t) s2[0];
      if (c1 - c2 != 0)
       return c1 - c2;
      ++s1;
      ++s2;
      --n;
    }
  if (n > 0)
    {
      c1 = (wint_t) s1[0];
      c2 = (wint_t) s2[0];
      if (c1 - c2 != 0)
       return c1 - c2;
    }

  return 0;
}