MCPcopy Create free account
hub / github.com/ddnet/ddnet / AddDataSwapped

Method AddDataSwapped

src/engine/shared/datafile.cpp:1104–1121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1102}
1103
1104int CDataFileWriter::AddDataSwapped(size_t Size, const void *pData)
1105{
1106 dbg_assert(Size > 0 && pData != nullptr, "Data missing");
1107 dbg_assert(Size <= (size_t)std::numeric_limits<int>::max(), "Data too large");
1108 dbg_assert(m_vDatas.size() < (size_t)std::numeric_limits<int>::max(), "Too many data");
1109 dbg_assert(Size % sizeof(int) == 0, "Invalid data boundary");
1110
1111#if defined(CONF_ARCH_ENDIAN_BIG)
1112 void *pSwapped = malloc(Size); // temporary buffer that we use during compression
1113 mem_copy(pSwapped, pData, Size);
1114 swap_endian(pSwapped, sizeof(int), Size / sizeof(int));
1115 int Index = AddData(Size, pSwapped);
1116 free(pSwapped);
1117 return Index;
1118#else
1119 return AddData(Size, pData);
1120#endif
1121}
1122
1123int CDataFileWriter::AddDataString(const char *pStr)
1124{

Callers 1

SaveMethod · 0.80

Calls 2

mem_copyFunction · 0.85
swap_endianFunction · 0.85

Tested by

no test coverage detected