From c3844502367df3d73744d707a40b836d7317453a Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Tue, 30 Dec 2014 22:20:29 -0500 Subject: [PATCH] Remove stale CSrvPackBuffer code --- .../pnNetProtocol/Private/pnNpCommon.cpp | 116 ------------------ .../pnNetProtocol/Private/pnNpCommon.h | 48 -------- 2 files changed, 164 deletions(-) diff --git a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp index 5638fcee..550acb3c 100644 --- a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp +++ b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp @@ -783,119 +783,3 @@ void NetVaultNode::SetBlob_1 (const uint8_t v[], uint32_t len) { void NetVaultNode::SetBlob_2 (const uint8_t v[], uint32_t len) { IVaultNodeSetBlob(kBlob_2, &blob_2, &blob_2Length, v, len); } - - -/***************************************************************************** -* -* CSrvPackBuffer -* -***/ - -//============================================================================ -CSrvPackBuffer::CSrvPackBuffer (unsigned bytes) { - m_data = (uint8_t *)malloc(bytes); - m_pos = m_data; - m_end = m_pos + bytes; -} - -//============================================================================ -void * CSrvPackBuffer::Alloc (unsigned bytes) { - ASSERT((signed) bytes >= 0); - ASSERT(m_pos + bytes <= m_end); - - uint8_t * pos = m_pos; - m_pos += bytes; - return pos; -} - -//============================================================================ -void CSrvPackBuffer::AddData (const void * ptr, unsigned bytes) { - memcpy(Alloc(bytes), ptr, bytes); -} - -//============================================================================ -void CSrvPackBuffer::AddString (const wchar_t str[]) { - AddData(str, StrBytes(str)); -} - -//============================================================================ -void CSrvPackBuffer::AddDWordArray (const uint32_t * arr, unsigned count) { - // Don't let large counts cause pointer wrap - count &= 0x00ffffff; - AddData(arr, count * sizeof(arr[0])); -} - -//============================================================================ -unsigned CSrvPackBuffer::Size () { - return m_pos - m_data; -} - - -/***************************************************************************** -* -* CSrvUnpackBuffer -* -***/ - -//============================================================================ -CSrvUnpackBuffer::CSrvUnpackBuffer (const void * buffer, unsigned count) { - m_pos = (const uint8_t *) buffer; - m_end = m_pos + count; -} - -//============================================================================ -const void * CSrvUnpackBuffer::GetData (unsigned bytes) { - for (;;) { - const uint8_t * result = m_pos; - m_pos += bytes; - - if (m_pos < result) - break; - if (m_pos > m_end) - break; - - return result; - } - - m_end = nil; - return nil; -} - -//============================================================================ -const wchar_t * CSrvUnpackBuffer::GetString () { - - if (m_end) { - const wchar_t * end = (const wchar_t *) (m_end - sizeof(wchar_t) + 1); - for (const wchar_t * cur = (const wchar_t *) m_pos; cur < end; ) { - if (*cur++) - continue; - - const wchar_t * pos = (const wchar_t *) m_pos; - m_pos = (const uint8_t *) cur; - return pos; - } - } - - m_end = NULL; - return NULL; -} - -//============================================================================ -const uint32_t * CSrvUnpackBuffer::GetDWordArray (unsigned count) { - // Don't let large counts cause pointer wrap - if (count & 0x00ffffff) - return (const uint32_t *)GetData(count * sizeof(uint32_t)); - - m_end = nil; - return nil; -} - -//============================================================================ -unsigned CSrvUnpackBuffer::BytesLeft () { - return m_end ? m_end - m_pos : 0; -} - -//============================================================================ -bool CSrvUnpackBuffer::ParseError () { - return !m_end; -} diff --git a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h index 3c838a49..a71ee99b 100644 --- a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h +++ b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h @@ -417,51 +417,3 @@ struct NetVaultNodeRef { bool seen; }; #pragma pack(pop) - -//============================================================================ -// SrvPackBuffer -//============================================================================ - -// Allocate a CSrvPackBuffer on the heap with one extra uint32_t to allow for padding -#define SRV_ALLOC_BUFFER(bytes) \ - new(malloc(sizeof(CSrvPackBuffer) + (bytes) + sizeof(uint32_t))) \ - CSrvPackBuffer(bytes + sizeof(uint32_t)) - -// Allocate a CSrvPackBuffer on the stack with one extra uint32_t to allow for padding -#define SRV_ALLOCA_BUFFER(bytes) \ - new(_alloca(sizeof(CSrvPackBuffer) + (bytes) + sizeof(uint32_t))) \ - CSrvPackBuffer(bytes + sizeof(uint32_t)) - -class CSrvPackBuffer { -public: - CSrvPackBuffer (unsigned bytes); - - void * Alloc (unsigned bytes); - void AddData (const void * ptr, unsigned bytes); - void AddString (const wchar_t str[]); - void AddDWordArray (const uint32_t * arr, unsigned count); - // add new "Add..." methods here as needed - - unsigned Size (); - -private: - uint8_t * m_pos; - uint8_t * m_end; - uint8_t * m_data; -}; - -class CSrvUnpackBuffer { -public: - CSrvUnpackBuffer (const void * buffer, unsigned count); - - const void * GetData (unsigned bytes); - const wchar_t * GetString (); - const uint32_t * GetDWordArray (unsigned count); - - unsigned BytesLeft (); - bool ParseError (); - -private: - const uint8_t * m_pos; - const uint8_t * m_end; -};