Browse Source

Replace MemZero with memset.

Darryl Pogue 13 years ago committed by Adam Johnson
parent
commit
72fdf8de32
  1. 2
      Sources/Plasma/CoreLib/hsMalloc.h
  2. 12
      Sources/Plasma/CoreLibExe/hsExeMalloc.cpp
  3. 14
      Sources/Plasma/FeatureLib/pfGameScoreMgr/pfGameScoreMgr.cpp
  4. 2
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtFile.cpp
  5. 4
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp
  6. 2
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/W9x/pnAceW9xFile.cpp
  7. 2
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Dns.cpp
  8. 6
      Sources/Plasma/NucleusLib/pnUtils/Private/pnUtArray.h

2
Sources/Plasma/CoreLib/hsMalloc.h

@ -84,8 +84,6 @@ unsigned MemSize (void * ptr);
int MemCmp (const void * buf1, const void * buf2, unsigned bytes);
void MemCopy (void * dest, const void * source, unsigned bytes);
void MemMove (void * dest, const void * source, unsigned bytes);
void MemSet (void * dest, unsigned value, unsigned bytes);
void MemZero (void * dest, unsigned bytes);
/*****************************************************************************

12
Sources/Plasma/CoreLibExe/hsExeMalloc.cpp

@ -487,7 +487,7 @@ void * MemAlloc (unsigned bytes, unsigned flags, const char file[], int line) {
// In debug mode ensure that memory is initialized to some freaky value
#ifdef HS_DEBUGGING
if (! (flags & kMemZero))
MemSet(ptr, (uint8_t) ((uintptr_t)ptr >> 4), bytes);
memset(ptr, (uint8_t) ((uintptr_t)ptr >> 4), bytes);
#endif
#ifdef _MSC_VER
@ -620,16 +620,6 @@ void MemMove (void * dest, const void * source, unsigned bytes) {
memmove(dest, source, bytes);
}
//===========================================================================
void MemSet (void * dest, unsigned value, unsigned bytes) {
memset(dest, value, bytes);
}
//===========================================================================
void MemZero (void * dest, unsigned bytes) {
memset(dest, 0, bytes);
}
//===========================================================================
void * MemDup (const void * ptr, unsigned bytes, unsigned flags, const char file[], int line) {
void * dst = MemAlloc(bytes, flags, file, line);

14
Sources/Plasma/FeatureLib/pfGameScoreMgr/pfGameScoreMgr.cpp

@ -178,7 +178,7 @@ ENetError pfGameScoreMgr::CreateScore(
pfGameScore& score
) {
CreateScoreOp param;
MemZero(&param, sizeof(CreateScoreOp));
memset(&param, 0, sizeof(CreateScoreOp));
param.score = &score;
NetCliAuthScoreCreate(
@ -205,7 +205,7 @@ ENetError pfGameScoreMgr::DeleteScore(
unsigned scoreId
) {
NetWaitOp param;
MemZero(&param, sizeof(NetWaitOp));
memset(&param, 0, sizeof(NetWaitOp));
NetCliAuthScoreDelete(
scoreId,
@ -277,7 +277,7 @@ ENetError pfGameScoreMgr::GetScoresIncRef(
int& outScoreListCount
) {
GetScoresOp param;
MemZero(&param, sizeof(GetScoresOp));
memset(&param, 0, sizeof(GetScoresOp));
param.scores = &outScoreList;
param.scoreCount = &outScoreListCount;
@ -304,7 +304,7 @@ ENetError pfGameScoreMgr::AddPoints(
int numPoints
) {
NetWaitOp param;
MemZero(&param, sizeof(NetWaitOp));
memset(&param, 0, sizeof(NetWaitOp));
NetCliAuthScoreAddPoints(
scoreId,
@ -336,7 +336,7 @@ ENetError pfGameScoreMgr::TransferPoints(
int numPoints
) {
NetWaitOp param;
MemZero(&param, sizeof(NetWaitOp));
memset(&param, 0, sizeof(NetWaitOp));
NetCliAuthScoreTransferPoints(
srcScoreId,
@ -371,7 +371,7 @@ ENetError pfGameScoreMgr::SetPoints(
int numPoints
) {
NetWaitOp param;
MemZero(&param, sizeof(NetWaitOp));
memset(&param, 0, sizeof(NetWaitOp));
NetCliAuthScoreSetPoints(
scoreId,
@ -448,7 +448,7 @@ ENetError pfGameScoreMgr::GetRankList(
int& outRankListCount
) {
GetRanksOp param;
MemZero(&param, sizeof(GetRanksOp));
memset(&param, 0, sizeof(GetRanksOp));
param.ranks = &outRankList;
param.rankCount = &outRankListCount;

2
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtFile.cpp

@ -448,7 +448,7 @@ bool INtFileOpCompleteReadWrite (
if (!file->sectorSizeMask)
ErrorFatal(__LINE__, __FILE__, "Disk %s failed", op->opType == kOpFileRead ? "read" : "write");
if (op->opType == kOpFileRead)
MemZero(op->rw.buffer + bytes, op->win32Bytes - bytes);
memset(op->rw.buffer + bytes, 0, op->win32Bytes - bytes);
}
if (op->masterOp) {

4
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp

@ -548,7 +548,7 @@ static SOCKET ListenSocket (NetAddress * listenAddr) {
addr.sin_family = AF_INET;
addr.sin_port = htons((uint16_t)port);
addr.sin_addr.S_un.S_addr = htonl(node);
MemZero(addr.sin_zero, sizeof(addr.sin_zero));
memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
if (bind(s, (sockaddr *) &addr, sizeof(addr))) {
wchar_t str[32];
NetAddressToString(*listenAddr, str, arrsize(str), kNetAddressFormatAll);
@ -632,7 +632,7 @@ static SOCKET ConnectSocket (unsigned localPort, const NetAddress & addr) {
addr.sin_family = AF_INET;
addr.sin_port = htons((uint16_t) localPort);
addr.sin_addr.S_un.S_addr = INADDR_ANY;
MemZero(addr.sin_zero, sizeof(addr.sin_zero));
memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
if (bind(s, (sockaddr *) &addr, sizeof(addr))) {
LogMsg(kLogError, "bind(port %u) failed (%u)", localPort, WSAGetLastError());
break;

2
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/W9x/pnAceW9xFile.cpp

@ -215,7 +215,7 @@ void CFile::Read (
// Handle errors
if (bytesRead != bytes)
MemZero((uint8_t *)buffer + bytesRead, bytes - bytesRead);
memset((uint8_t *)buffer + bytesRead, 0, bytes - bytesRead);
if ( (!result && (GetLastError() != ERROR_IO_PENDING)) ||
(bytesRead != bytes) )
LogMsg(kLogFatal, "failed: ReadFile");

2
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Dns.cpp

@ -110,7 +110,7 @@ static void LookupProcess (Lookup * lookup, unsigned error) {
// allocate a buffer large enough to hold all the addresses
addrs = (NetAddress *)malloc(sizeof(*addrs) * count);
MemZero(addrs, sizeof(*addrs) * count);
memset(addrs, 0, sizeof(*addrs) * count);
// fill in address data
const uint16_t port = htons((uint16_t) lookup->port);

6
Sources/Plasma/NucleusLib/pnUtils/Private/pnUtArray.h

@ -260,7 +260,7 @@ void TBuffer<T>::SetCount (unsigned count) {
template<class T>
void TBuffer<T>::Zero () {
if (m_data)
MemZero(m_data, Bytes());
memset(m_data, 0, Bytes());
}
typedef TBuffer<uint8_t> CBuffer;
@ -678,7 +678,7 @@ const T * TFArray<T,C>::Top () const {
template<class T, class C>
void TFArray<T,C>::Zero () {
C::Destruct(m_data, m_count);
MemZero(m_data, m_count * sizeof(T));
memset(m_data, 0, m_count * sizeof(T));
C::Construct(m_data, m_count);
}
@ -694,7 +694,7 @@ template<class T, class C>
void TFArray<T,C>::ZeroRange (unsigned index, unsigned count) {
ASSERT(index + count <= m_count);
C::Destruct(m_data + index, count);
MemZero(m_data + index, count * sizeof(T));
memset(m_data + index, 0, count * sizeof(T));
C::Construct(m_data + index, count);
}

Loading…
Cancel
Save