SUMMARY:  INNER | FIELD | CONSTR | METHOD | FRIEND DETAIL:  FIELD | CONSTR | METHOD | FRIEND


Namespace Platform::Mem

namespace Platform::Mem

Provides operations for manipulating memory blocks (copying, comparison etc).

Inner Compounds, Typedefs, and Enumscollapse
struct Reader
          DOCTODO.
struct Reader<True>
          DOCTODO.
struct Writer
          DOCTODO.
struct Writer<True>
          DOCTODO.

Method Summarycollapse
Int compare(const Void* pointerA, const Void* pointerB, Int size)
          Compares the contents of two memory regions.
Void copy(Void* destination, const Void* source, Int size)
          Copies an array of bytes from one memory region to another. Memory regions may overlap.
Void copyBackward(Void* destination, const Void* source, Int size)
          Copies an array of bytes from one memory region to another in reverse direction.
Void copyForward(Void* destination, const Void* source, Int size)
          Copies an array of bytes from one memory region to another in forward direction.
Void fill(Void* destination, Byte value, Int size)
          Fills a memory region with a specified value.
Void swap(Void* pointerA, Void* pointerB, Int size)
          Swaps the contents of two memory regions.
Void zero(Void* destination, Int size)
          Fills a memory region with zeros.

 

Method Detail

compare[nothrow, inline]

Int compare(const Void* pointerA, const Void* pointerB, Int size)

Compares size bytes of two memory regions pointed to by pointerA and pointerB.

Parameters:
pointerA - pointer to the first byte of the first memory region.
pointerB - pointer to the first byte of the second memory region.
size - the number of bytes to compare.
Returns:
The relationship between memory regions:

Return value Relationship
< 0 contents of the first memory region is less than contents of the second memory region (A < B)
0 contents of the first memory region is identical to contents of the second memory region (A == B)
> 0 contents of the first memory region is greater than contents of the second memory region (A > B)
Preconditions:
pointerA and pointerB are valid memory addresses pointing to readable memory regions, size >= 0.
Remarks:
The effect of this function is equivalent to calling standard C function memcmp(pointerA, pointerB, size). This function returns 0 if the value of the size argument is 0.

copy[nothrow, inline]

Void copy(Void* destination, const Void* source, Int size)

Copies size bytes from source into destination buffer which must be large enough to hold the result. This function can handle overlapping memory regions by selecting the appropriate copy method, either forward or backward copy, employing the following logic:
    if(destination <= source || destination >= (source + size))
        copyForward(destination, source, size);
    else
        copyBackward(destination, source, size);
Parameters:
destination - pointer to the first byte of the destination memory region which is to receive bytes copied.
source - pointer to the first byte of the source memory region which is to be copied.
size - size of the source memory region, in bytes.
Preconditions:
destination and source are valid memory addresses pointing to writeable and readable memory regions respective, size >= 0.
Remarks:
The effect of this function is equivalent to calling standard C function memmove(destination, source, size). This function has no effect if the value of the size argument is 0.
See Also:
copyForward, copyBackward

copyBackward[nothrow, inline]

Void copyBackward(Void* destination, const Void* source, Int size)

Copies size bytes from source into destination buffer which must be large enough to hold the result. This function transfers data in reverse direction: the last byte is copied first, source and destination addresses are decremented until all bytes are copied.

Note that unlike copy, this function may not be able to correctly handle overlapping memory regions. If two memory regions overlap the result of this function is undefined.

Parameters:
destination - pointer to the first byte of the destination memory region which is to receive bytes copied.
source - pointer to the first byte of the source memory region which is to be copied.
size - size of the source memory region, in bytes.
Preconditions:
destination and source are valid memory addresses pointing to writeable and readable memory regions respective, size >= 0.
Remarks:
The effect of this function is equivalent to calling standard C function memmove(destination, source, size). This function has no effect if the value of the size argument is 0.
See Also:
copy

copyForward[nothrow, inline]

Void copyForward(Void* destination, const Void* source, Int size)

Copies size bytes from source into destination buffer which must be large enough to hold the result. This function transfers data in forward direction: the first byte is copied first, source and destination addresses are incremented until all bytes are copied.

Note that unlike copy, this function may not be able to correctly handle overlapping memory regions. If two memory regions overlap the result of this function is undefined.

Parameters:
destination - pointer to the first byte of the destination memory region which is to receive bytes copied.
source - pointer to the first byte of the source memory region which is to be copied.
size - size of the source memory region, in bytes.
Preconditions:
destination and source are valid memory addresses pointing to writeable and readable memory regions respective, size >= 0.
Remarks:
The effect of this function is equivalent to calling standard C function memcpy(destination, source, size). This function has no effect if the value of the size argument is 0.
See Also:
copy

fill[nothrow, inline]

Void fill(Void* destination, Byte value, Int size)

Sets the contents of the destination memory region to the specified value.

Parameters:
destination - pointer to the first byte of the destination memory region which is to be filled with value.
value - Byte value with which to fill the destination memory region.
size - size of the destination memory region, in bytes.
Preconditions:
destination is a valid memory address pointing to a writeable memory region, size >= 0.
Remarks:
The effect of this function is equivalent to calling standard C function memset(destination, value, size). This function has no effect if the value of the size argument is 0.

swap[nothrow, inline]

Void swap(Void* pointerA, Void* pointerB, Int size)

Exchanges size bytes of two memory regions pointed to by pointerA and pointerB.

Parameters:
pointerA - pointer to the first byte of the first memory region.
pointerB - pointer to the first byte of the second memory region.
size - the number of bytes to exchange.
Preconditions:
pointerA and pointerB are valid memory addresses pointing to writeable memory regions, size >= 0.
Remarks:
This function has no effect if the value of the size argument is 0.

zero[nothrow, inline]

Void zero(Void* destination, Int size)

Clears the destination memory region by filling its contents with zeroes.

Parameters:
destination - pointer to the first byte of the destination memory region which is to be cleared.
size - size of the destination memory region, in bytes.
Preconditions:
destination is a valid memory address pointing to a writeable memory region, size >= 0.
Remarks:
The effect of this function is equivalent to calling standard C function memset(destination, 0, size). This function has no effect if the value of the size argument is 0.


SUMMARY:  INNER | FIELD | CONSTR | METHOD | FRIEND DETAIL:  FIELD | CONSTR | METHOD | FRIEND