mirror of https://github.com/postgres/postgres
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
861 B
37 lines
861 B
![]()
24 years ago
|
/*-------------------------------------------------------------------------
|
||
|
*
|
||
|
* memcmp.c
|
||
|
* compares memory bytes
|
||
|
*
|
||
![]()
24 years ago
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||
![]()
24 years ago
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||
|
*
|
||
|
*
|
||
|
* IDENTIFICATION
|
||
![]()
23 years ago
|
* $Header: /cvsroot/pgsql/src/port/memcmp.c,v 1.1 2002/07/18 04:13:59 momjian Exp $
|
||
![]()
24 years ago
|
*
|
||
|
* This file was taken from NetBSD and is used by SunOS because memcmp
|
||
|
* on that platform does not properly compare negative bytes.
|
||
|
*
|
||
|
*-------------------------------------------------------------------------
|
||
|
*/
|
||
|
|
||
|
#include <string.h>
|
||
|
|
||
|
/*
|
||
|
* Compare memory regions.
|
||
|
*/
|
||
|
int
|
||
|
memcmp(const void *s1, const void *s2, size_t n)
|
||
|
{
|
||
|
if (n != 0) {
|
||
|
const unsigned char *p1 = s1, *p2 = s2;
|
||
|
|
||
|
do {
|
||
|
if (*p1++ != *p2++)
|
||
|
return (*--p1 - *--p2);
|
||
|
} while (--n != 0);
|
||
|
}
|
||
|
return 0;
|
||
|
}
|