File: memcmp.c

package info (click to toggle)
npadmin 0.8-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 524 kB
  • ctags: 792
  • sloc: cpp: 3,514; ansic: 1,176; sh: 327; makefile: 52
file content (14 lines) | stat: -rw-r--r-- 322 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* Naive substitute implementation of memcmp() */

#include <sys/types.h>

int memcmp(const void *s1, const void *s2, size_t n){
  size_t counter = 0;
  for (;counter < n; counter++) {
    int res = ((unsigned char*)s1)[counter] -
      ((unsigned char*)s2)[counter];
    if (0 != res)
      return res;
  }
  return 0;
}