Ruby: missing/memcmp.c Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

memcmp.c
Go to the documentation of this file.
1/* public domain rewrite of memcmp(3) */
2
3#include "ruby/missing.h"
4#include <stddef.h>
5
6int
7memcmp(const void *s1, const void *s2, size_t len)
8{
9 register unsigned char *a = (unsigned char*)s1;
10 register unsigned char *b = (unsigned char*)s2;
11 register int tmp;
12
13 for (; len; --len) {
14 tmp = *a++ - *b++;
15 if (tmp)
16 return tmp;
17 }
18 return 0;
19}
len
uint8_t len
Definition: escape.c:17
missing.h
Prototype for *.c in ./missing, and for missing timeval struct.
memcmp
int memcmp(const void *s1, const void *s2, size_t len)
Definition: memcmp.c:7