OpenTTD Source: src/core/mem_func.hpp File Reference

OpenTTD Source 15.0-beta1

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 >
void | MemCpyT (T *destination, const T *source, size_t num=1)
| Type-safe version of memcpy().
template<typename T >
void | MemMoveT (T *destination, const T *source, size_t num=1)
| Type-safe version of memmove().
template<typename T >
void | MemSetT (T *ptr, uint8_t value, size_t num=1)
| Type-safe version of memset().
template<typename T >
int | MemCmpT (const T *ptr1, const T *ptr2, size_t num=1)
| Type-safe version of memcmp().

## Detailed Description

Functions related to memory operations.

Definition in file mem_func.hpp.

## Function Documentation

## ◆ MemCmpT()

template<typename T >

int MemCmpT | ( | const T * | ptr1,
|  | const T * | ptr2,
|  | size_t | num = `1`
| ) |  |
| inline

Type-safe version of memcmp().

Parameters

  ptr1 | Pointer to the first buffer
  ptr2 | Pointer to the second buffer
  num | Number 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 63 of file mem_func.hpp.

Referenced by GRFGetSizeOfDataSection(), and MidiFile::ReadSMFHeader().

## ◆ MemCpyT()

template<typename T >

void MemCpyT | ( | T * | destination,
|  | const T * | source,
|  | size_t | num = `1`
| ) |  |
| inline

Type-safe version of memcpy().

Parameters

  destination | Pointer to the destination buffer
  source | Pointer to the source buffer
  num | number of items to be copied. (!not number of bytes!)

Definition at line 23 of file mem_func.hpp.

Referenced by OutputBuffer::Add(), NewGRFSpriteLayout::Clone(), NewGRFSpriteLayout::Clone(), Blitter_8bppOptimized::Draw(), and ErrorMessageData::ErrorMessageData().

## ◆ MemMoveT()

template<typename T >

void MemMoveT | ( | T * | destination,
|  | const T * | source,
|  | size_t | num = `1`
| ) |  |
| inline

Type-safe version of memmove().

Parameters

  destination | Pointer to the destination buffer
  source | Pointer to the source buffer
  num | number of items to be copied. (!not number of bytes!)

Definition at line 36 of file mem_func.hpp.

## ◆ MemSetT()

template<typename T >

void MemSetT | ( | T * | ptr,
|  | uint8_t | value,
|  | size_t | num = `1`
| ) |  |
| inline

Type-safe version of memset().

Parameters

  ptr | Pointer to the destination buffer
  value | Value to be set
  num | number of items to be set (!not number of bytes!)

Definition at line 49 of file mem_func.hpp.

Referenced by VideoDriver_SDL_OpenGL::AllocateBackingStore(), DEFINE_POOL_METHOD(), Blitter_8bppOptimized::Draw(), DLSFile::LoadFile(), LoadWin32Font(), OpenGLSprite::OpenGLSprite(), StringReader::ParseFile(), DLSFile::ReadDLSWave(), VideoDriver_SDL_OpenGL::ReleaseVideoPointer(), MusicSystem::SaveCustomPlaylist(), MusicDriver_DMusic::Start(), and StationChangeInfo().