Back to index

openldap  2.4.31
memcmp.c
Go to the documentation of this file.
00001 /* $OpenLDAP$ */
00002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00003  *
00004  * Copyright 1998-2012 The OpenLDAP Foundation.
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted only as authorized by the OpenLDAP
00009  * Public License.
00010  *
00011  * A copy of this license is available in the file LICENSE in the
00012  * top-level directory of the distribution or, alternatively, at
00013  * <http://www.OpenLDAP.org/license.html>.
00014  */
00015 
00016 #include "portable.h"
00017 
00018 #include <ac/string.h>
00019 
00020 /* 
00021  * Memory Compare
00022  */
00023 int
00024 (lutil_memcmp)(const void *v1, const void *v2, size_t n) 
00025 {
00026     if (n != 0) {
00027               const unsigned char *s1=v1, *s2=v2;
00028         do {
00029             if (*s1++ != *s2++) return *--s1 - *--s2;
00030         } while (--n != 0);
00031     }
00032     return 0;
00033 }