src/core/mem_func.hpp
changeset 9575 58d55b1a70c9
parent 9521 5d01c4545f24
equal deleted inserted replaced
9574:7ff7285bf59f 9575:58d55b1a70c9
    14  * @param destination Pointer to the destination buffer
    14  * @param destination Pointer to the destination buffer
    15  * @param source Pointer to the source buffer
    15  * @param source Pointer to the source buffer
    16  * @param num number of items to be copied. (!not number of bytes!)
    16  * @param num number of items to be copied. (!not number of bytes!)
    17  */
    17  */
    18 template <typename T>
    18 template <typename T>
    19 FORCEINLINE void MemCpyT(T *destination, const T *source, uint num = 1)
    19 static FORCEINLINE void MemCpyT(T *destination, const T *source, uint num = 1)
    20 {
    20 {
    21 	memcpy(destination, source, num * sizeof(T));
    21 	memcpy(destination, source, num * sizeof(T));
    22 }
    22 }
    23 
    23 
    24 /**
    24 /**
    27  * @param destination Pointer to the destination buffer
    27  * @param destination Pointer to the destination buffer
    28  * @param source Pointer to the source buffer
    28  * @param source Pointer to the source buffer
    29  * @param num number of items to be copied. (!not number of bytes!)
    29  * @param num number of items to be copied. (!not number of bytes!)
    30  */
    30  */
    31 template <typename T>
    31 template <typename T>
    32 FORCEINLINE void MemMoveT(T *destination, const T *source, uint num = 1)
    32 static FORCEINLINE void MemMoveT(T *destination, const T *source, uint num = 1)
    33 {
    33 {
    34 	memmove(destination, source, num * sizeof(T));
    34 	memmove(destination, source, num * sizeof(T));
    35 }
    35 }
    36 
    36 
    37 /**
    37 /**
    40  * @param ptr Pointer to the destination buffer
    40  * @param ptr Pointer to the destination buffer
    41  * @param value Value to be set
    41  * @param value Value to be set
    42  * @param num number of items to be set (!not number of bytes!)
    42  * @param num number of items to be set (!not number of bytes!)
    43  */
    43  */
    44 template <typename T>
    44 template <typename T>
    45 FORCEINLINE void MemSetT(T *ptr, int value, uint num = 1)
    45 static FORCEINLINE void MemSetT(T *ptr, int value, uint num = 1)
    46 {
    46 {
    47 	memset(ptr, value, num * sizeof(T));
    47 	memset(ptr, value, num * sizeof(T));
    48 }
    48 }
    49 
    49 
    50 /**
    50 /**
    54  * @param ptr2 Pointer to the second buffer
    54  * @param ptr2 Pointer to the second buffer
    55  * @param num Number of items to compare. (!not number of bytes!)
    55  * @param num Number of items to compare. (!not number of bytes!)
    56  * @return an int value indicating the relationship between the content of the two buffers
    56  * @return an int value indicating the relationship between the content of the two buffers
    57  */
    57  */
    58 template <typename T>
    58 template <typename T>
    59 FORCEINLINE int MemCmpT(const T *ptr1, const T *ptr2, uint num = 1)
    59 static FORCEINLINE int MemCmpT(const T *ptr1, const T *ptr2, uint num = 1)
    60 {
    60 {
    61 	return memcmp(ptr1, ptr2, num * sizeof(T));
    61 	return memcmp(ptr1, ptr2, num * sizeof(T));
    62 }
    62 }
    63 
    63 
    64 /**
    64 /**
    67  *  type of the pointers.
    67  *  type of the pointers.
    68  *
    68  *
    69  * @param ptr1 Start-pointer to the block of memory.
    69  * @param ptr1 Start-pointer to the block of memory.
    70  * @param ptr2 End-pointer to the block of memory.
    70  * @param ptr2 End-pointer to the block of memory.
    71  */
    71  */
    72 template<typename T>
    72 template <typename T>
    73 FORCEINLINE void MemReverseT(T *ptr1, T *ptr2)
    73 static FORCEINLINE void MemReverseT(T *ptr1, T *ptr2)
    74 {
    74 {
    75 	assert(ptr1 != NULL && ptr2 != NULL);
    75 	assert(ptr1 != NULL && ptr2 != NULL);
    76 	assert(ptr1 < ptr2);
    76 	assert(ptr1 < ptr2);
    77 
    77 
    78 	do {
    78 	do {
    84  * Type safe memory reverse operation (overloaded)
    84  * Type safe memory reverse operation (overloaded)
    85  *
    85  *
    86  * @param ptr Pointer to the block of memory.
    86  * @param ptr Pointer to the block of memory.
    87  * @param num The number of items we want to reverse.
    87  * @param num The number of items we want to reverse.
    88  */
    88  */
    89 template<typename T>
    89 template <typename T>
    90 FORCEINLINE void MemReverseT(T *ptr, uint num)
    90 static FORCEINLINE void MemReverseT(T *ptr, uint num)
    91 {
    91 {
    92 	assert(ptr != NULL);
    92 	assert(ptr != NULL);
    93 
    93 
    94 	MemReverseT(ptr, ptr + (num - 1));
    94 	MemReverseT(ptr, ptr + (num - 1));
    95 }
    95 }