Memory Operations¶
Set¶
Fills a block of memory with the specified byte value.
Example¶
Zero¶
Fills a block of memory with zeros.
Example¶
Compare¶
Compares two memory regions.
Parameters¶
| Parameter | Description |
|---|---|
lhs |
First memory block. |
rhs |
Second memory block. |
length |
Number of bytes to compare. |
Return Value¶
Returns a platform-dependent comparison result.
Platform Differences¶
| Platform | Return Value | Implementation |
|---|---|---|
| Linux / BSD / Illumos / macOS | Index of the first differing byte (length if equal) |
Byte-by-byte comparison loop |
| Windows | Number of matching bytes (length if equal) |
RtlCompareMemory |
Both conventions yield the same numeric value at a given mismatch position.
Example¶
Notes¶
Use this function only to determine whether memory regions differ, not to interpret ordering semantics.
Because the return values have different meanings across platforms, portable code should only rely on the following guarantee:
This indicates that all compared bytes are equal.
Code should not rely on any other specific return value.
Copy¶
Copies bytes from one memory location to another.
Parameters¶
| Parameter | Description |
|---|---|
dest |
Destination memory block. |
src |
Source memory block. |
length |
Number of bytes to copy. |
Example¶
Notes¶
Source and destination memory regions must be valid for at least length bytes.