Ruby: missing/memcmp.c Source File

Ruby 3.3.7p123 (2025-01-15 revision be31f993d7fa0219d85f7b3c694d454da4ecc10b)

memcmp.c
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
int len
Length of the buffer.
Definition io.h:8