comparison mupdf-source/thirdparty/jbig2dec/memcmp.c @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 /* Copyright (C) 2001-2023 Artifex Software, Inc.
2 All Rights Reserved.
3
4 This software is provided AS-IS with no warranty, either express or
5 implied.
6
7 This software is distributed under license and may not be copied,
8 modified or distributed except as expressly authorized under the terms
9 of the license contained in the file LICENSE in this distribution.
10
11 Refer to licensing information at http://www.artifex.com or contact
12 Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
13 CA 94129, USA, for further information.
14 */
15
16 /*
17 jbig2dec
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <stddef.h>
25
26 /* replacement for broken memcmp() */
27
28 /*
29 * compares two byte strings 'a' and 'b', both assumed to be 'len' bytes long
30 * returns zero if the two strings are identical, otherwise returns -1 or 1
31 * depending on the relative magnitude of the first differing elements,
32 * considered as unsigned chars
33 */
34
35 int
36 memcmp(const void *b1, const void *b2, size_t len)
37 {
38 unsigned char *a, *b;
39 size_t i;
40
41 a = (unsigned char *)b1;
42 b = (unsigned char *)b2;
43 for (i = 0; i < len; i++) {
44 if (*a != *b) {
45 /* strings differ */
46 return (*a < *b) ? -1 : 1;
47 }
48 a++;
49 b++;
50 }
51
52 /* strings match */
53 return 0;
54 }