OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

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

## Detailed Description

Functions related to memory operations.

Definition in file mem_func.hpp.

## Function Documentation

template<typename T >

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

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 65 of file mem_func.hpp.

Referenced by CheckCaches(), and GRFGetSizeOfDataSection().

template<typename T >

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

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 25 of file mem_func.hpp.

Referenced by OutputBuffer::Add(), TileMatrix< uint32, 4 >::AllocateStorage(), SmallMatrix< BaseEdge >::Assign(), CheckCaches(), NewGRFSpriteLayout::Clone(), CopyInDParam(), CopyOutDParam(), Blitter_8bppOptimized::Draw(), DuplicateTileTable(), ErrorMessageData::ErrorMessageData(), GRFFile::GRFFile(), ResetObjects(), HouseOverrideManager::SetEntitySpec(), and TownHouseChangeInfo().

template<typename T >

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

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 38 of file mem_func.hpp.

Referenced by SmallMatrix< BaseEdge >::EraseColumnPreservingOrder(), SmallVector< RefitOption, 32 >::ErasePreservingOrder(), SmallMatrix< BaseEdge >::EraseRowPreservingOrder(), and StringParameters::ShiftParameters().

template<typename T >

static void MemReverseT | ( | T * | ptr1,
|  | T * | ptr2
| ) |  |
| inline static

Type safe memory reverse operation.

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

Parameters

  ptr1 | Start-pointer to the block of memory.
  ptr2 | End-pointer to the block of memory.

Definition at line 79 of file mem_func.hpp.

References Swap().

Referenced by MemReverseT(), QSortT(), and GUIList< const Sign *, StringFilter & >::ToggleSortOrder().

template<typename T >

static void MemReverseT | ( | T * | ptr,
|  | size_t | num
| ) |  |
| inline static

Type safe memory reverse operation (overloaded)

Parameters

  ptr | Pointer to the block of memory.
  num | The number of items we want to reverse.

Definition at line 96 of file mem_func.hpp.

References MemReverseT().

template<typename T >

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

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 51 of file mem_func.hpp.

Referenced by AfterLoadCompanyStats(), AllocateSound(), BuildRiver(), StringParameters::ClearTypeInformation(), CargoesRow::ConnectIndustryAccepted(), CargoesRow::ConnectIndustryProduced(), DisplaySplashImage(), Blitter_8bppOptimized::Draw(), HeightMapCurves(), LoadNewGRFSound(), CargoesField::MakeCargo(), CargoesRow::MakeCargoLabel(), CargoesField::MakeIndustry(), StringReader::ParseFile(), ReadSpriteLayout(), ResetObjects(), IniFile::SaveToDisk(), and StationChangeInfo().