OpenTTD
Functions
mem_func.hpp File Reference

Functions related to memory operations. More...

#include "math_func.hpp"

Go to the source code of this file.

Functions

template<typename T >
static void MemCpyT (T *destination, const T *source, size_t num=1)
 Type-safe version of memcpy(). More...
 
template<typename T >
static void MemMoveT (T *destination, const T *source, size_t num=1)
 Type-safe version of memmove(). More...
 
template<typename T >
static void MemSetT (T *ptr, byte value, size_t num=1)
 Type-safe version of memset(). More...
 
template<typename T >
static int MemCmpT (const T *ptr1, const T *ptr2, size_t num=1)
 Type-safe version of memcmp(). More...
 
template<typename T >
static void MemReverseT (T *ptr1, T *ptr2)
 Type safe memory reverse operation. More...
 
template<typename T >
static void MemReverseT (T *ptr, size_t num)
 Type safe memory reverse operation (overloaded) More...
 

Detailed Description

Functions related to memory operations.

Definition in file mem_func.hpp.

Function Documentation

◆ MemCmpT()

template<typename T >
static int MemCmpT ( const T *  ptr1,
const T *  ptr2,
size_t  num = 1 
)
inlinestatic

Type-safe version of memcmp().

Parameters
ptr1Pointer to the first buffer
ptr2Pointer to the second buffer
numNumber of items to compare. (!not number of bytes!)
Returns
an int value indicating the relationship between the content of the two buffers

Definition at line 65 of file mem_func.hpp.

Referenced by GRFGetSizeOfDataSection().

◆ MemCpyT()

template<typename T >
static void MemCpyT ( T *  destination,
const T *  source,
size_t  num = 1 
)
inlinestatic

Type-safe version of memcpy().

Parameters
destinationPointer to the destination buffer
sourcePointer to the source buffer
numnumber of items to be copied. (!not number of bytes!)

Definition at line 25 of file mem_func.hpp.

Referenced by SmallMatrix< BaseEdge >::Assign(), NewGRFSpriteLayout::Clone(), CopyInDParam(), CopyOutDParam(), DuplicateTileTable(), ResetObjects(), HouseOverrideManager::SetEntitySpec(), and TownHouseChangeInfo().

◆ MemMoveT()

template<typename T >
static void MemMoveT ( T *  destination,
const T *  source,
size_t  num = 1 
)
inlinestatic

Type-safe version of memmove().

Parameters
destinationPointer to the destination buffer
sourcePointer to the source buffer
numnumber of items to be copied. (!not number of bytes!)

Definition at line 38 of file mem_func.hpp.

◆ MemReverseT() [1/2]

template<typename T >
static void MemReverseT ( T *  ptr1,
T *  ptr2 
)
inlinestatic

Type safe memory reverse operation.

Reverse a block of memory in steps given by the type of the pointers.

Parameters
ptr1Start-pointer to the block of memory.
ptr2End-pointer to the block of memory.

Definition at line 79 of file mem_func.hpp.

Referenced by GUIList< const Company *>::ToggleSortOrder().

◆ MemReverseT() [2/2]

template<typename T >
static void MemReverseT ( T *  ptr,
size_t  num 
)
inlinestatic

Type safe memory reverse operation (overloaded)

Parameters
ptrPointer to the block of memory.
numThe number of items we want to reverse.

Definition at line 96 of file mem_func.hpp.

◆ MemSetT()

template<typename T >
static void MemSetT ( T *  ptr,
byte  value,
size_t  num = 1 
)
inlinestatic

Type-safe version of memset().

Parameters
ptrPointer to the destination buffer
valueValue to be set
numnumber of items to be set (!not number of bytes!)

Definition at line 51 of file mem_func.hpp.

Referenced by AllocateSound(), BuildRiver(), CargoesField::MakeCargo(), CargoesRow::MakeCargoLabel(), CargoesField::MakeIndustry(), ReadSpriteLayout(), and ResetObjects().