Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
8436 maxcodehac 1
/*
2
    jbig2dec
3
 
4
    Copyright (C) 2001-2005 Artifex Software, Inc.
5
 
6
    This software is distributed under license and may not
7
    be copied, modified or distributed except as expressly
8
    authorized under the terms of the license contained in
9
    the file LICENSE in this distribution.
10
 
11
    For further licensing information refer to http://artifex.com/ or
12
    contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
13
    San Rafael, CA  94903, U.S.A., +1(415)492-9861.
14
*/
15
 
16
#ifdef HAVE_CONFIG_H
17
#include "config.h"
18
#endif
19
 
20
#include 
21
 
22
/* replacement for broken memcmp() */
23
 
24
/*
25
 * compares two byte strings 'a' and 'b', both assumed to be 'len' bytes long
26
 * returns zero if the two strings are identical, otherwise returns -1 or 1
27
 * depending on the relative magnitude of the first differing elements,
28
 * considered as unsigned chars
29
 */
30
 
31
int memcmp(const void *b1, const void *b2, size_t len)
32
{
33
	unsigned char *a, *b;
34
	size_t i;
35
 
36
	a = (unsigned char *)b1;
37
	b = (unsigned char *)b2;
38
	for(i = 0; i < len; i++) {
39
		if (*a != *b) {
40
			 /* strings differ */
41
			return (*a < *b) ? -1 : 1;
42
		}
43
		a++;
44
		b++;
45
	}
46
 
47
	/* strings match */
48
	return 0;
49
}