CRE Programmer's Guide

String and Memory Block Functions
Common Run-Time Environment (CRE) Programmer’s Guide528146-004
8-34
Memory_Compare
Memory_Compare
The Memory_Compare functions compare two blocks of memory. These functions are
not available in the native CRE library.
buf1
is a pointer to the first block of memory.
buf2
is a pointer to the second block of memory.
num_bytes
specifies the number of bytes to compare.
Return Value
Memory_Compare returns a number that is:
< 0 if buf1 < buf2
0 if buf1 = buf2
> 0
if buf1 > buf2
Considerations
The Memory_Compare functions perform an unsigned byte comparison for a
maximum count of
num_bytes.
For less-than and greater-than comparisons, characters in buf1 and buf2 are
compared using the characters’ values in the ASCII collating sequence.
Example
INT i;
STRING .a1[0:7] := "12345678";
STRING .a2[0:10] := "12344678";
i := RTL_Memory_Compare_(a1, a2, 8); ! i gets 1
INT PROC RTL_Memory_Compare_( buf1, buf2, num_bytes );
STRING .buf1; ! in
STRING .buf2; ! in
INT num_bytes; ! in TNS
only
INT PROC RTL_Memory_CompareX_( buf1, buf2, num_bytes );
STRING .EXT buf1; ! in
STRING .EXT buf2; ! in
INT(32) num_bytes; ! in TNS
only