cmp


Description:

[ CCode ( cname = "memcmp" ) ]
public int cmp (void* s1, void* s2, size_t n)

Copies count characters from the object pointed to by src to the object pointed to by dest.

If the objects overlap, the behavior is undefined.

Example: Compare two blocks of memory:

public struct TestStruct {
public int a;
public int b;

public TestStruct (int a, int b) {
this.a = a;
this.b = b;
}
}

public static int main (string[] args) {
TestStruct a = TestStruct (1, 2);
TestStruct b = TestStruct (1, 2);

// Output: ``0``
int res = Memory.cmp (&a, &b, sizeof (TestStruct));
print ("cmp (a, b) = %d\n", res);

return 0;
}

valac --pkg glib-2.0 GLib.Memory.cmp.vala

Parameters:

s1

pointer to the memory location to copy to

s2

pointer to the memory location to copy from

n

number of bytes to copy

Returns:

dest


Namespace: GLib.Memory
Package: glib-2.0