]> git.sur5r.net Git - openldap/blob - libraries/liblutil/memcmp.c
d781183c1c7bb51150a63b06ccca37fedfbd7fcb
[openldap] / libraries / liblutil / memcmp.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 #include "portable.h"
7
8 #include <ac/string.h>
9
10 /* 
11  * Memory Compare
12  */
13 int
14 (memcmp)(const void *v1, const void *v2, int n) 
15 {
16     if (n != 0) {
17                 const unsigned char *s1=v1, *s2=v2;
18         do {
19             if (*s1++ != *s2++)
20                 return (*--s1 - *--s2);
21         } while (--n != 0);
22     }
23     return (0);
24