Here you can find the source of memcmp(byte[] s1, int s1Size, int s1offset, byte[] s2, int s2Size, int s2offset)
Parameter | Description |
---|---|
s1 | a parameter |
s1offset | a parameter |
s2 | a parameter |
n | a parameter |
public final static int memcmp(byte[] s1, int s1Size, int s1offset, byte[] s2, int s2Size, int s2offset)
//package com.java2s; public class Main { /**//from w w w. j av a2 s .com * Equiv of C library memcmp(). * * @param s1 * @param s1offset * @param s2 * @param n * @return */ public final static int memcmp(byte[] s1, int s1Size, int s1offset, byte[] s2, int s2Size, int s2offset) { int n = s1Size - s1offset; if (n > (s2Size - s2offset)) { n = s2Size - s2offset; } for (int i = 0; i < n; i++) { if (s1[i + s1offset] != s2[i + s2offset]) { return s1[i + s1offset] < s2[i + s2offset] ? -1 : 1; } } return 0; } }