From 6f9cff0c124b9d645e2458bf1aaa7fa71ac6bbaf Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 7 Dec 2017 16:35:55 +0000 Subject: [PATCH] Consistently use array count that has been flushed to 0 for NULL arrays * This means we don't have a lingering size >0 for an array that won't be used for NULL. Mostly on read this is immaterial but on write it is significant. --- renderdoc/serialise/serialiser.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/renderdoc/serialise/serialiser.h b/renderdoc/serialise/serialiser.h index f909e5b31..b1d751d78 100644 --- a/renderdoc/serialise/serialiser.h +++ b/renderdoc/serialise/serialiser.h @@ -243,7 +243,7 @@ public: SDObject &obj = *m_StructureStack.back(); obj.type.basetype = SDBasic::Buffer; - obj.type.byteSize = byteSize; + obj.type.byteSize = count; } byte *tempAlloc = NULL; @@ -255,9 +255,9 @@ public: m_Write->AlignTo(); if(el) - m_Write->Write(el, byteSize); + m_Write->Write(el, count); else - RDCASSERT(byteSize == 0); + RDCASSERT(count == 0); } else if(IsReading()) { @@ -270,8 +270,8 @@ public: #if !defined(__COVERITY__) if(flags & SerialiserFlags::AllocateMemory) { - if(byteSize > 0) - el = AllocAlignedBuffer(byteSize); + if(count > 0) + el = AllocAlignedBuffer(count); else el = NULL; } @@ -281,14 +281,14 @@ public: // allocation. if(el == NULL && ExportStructure() && m_ExportBuffers) { - if(byteSize > 0) - el = tempAlloc = AllocAlignedBuffer(byteSize); + if(count > 0) + el = tempAlloc = AllocAlignedBuffer(count); else el = NULL; } #endif - m_Read->Read(el, byteSize); + m_Read->Read(el, count); } } @@ -301,9 +301,9 @@ public: obj.data.basic.u = m_StructuredFile->buffers.size(); bytebuf *alloc = new bytebuf; - alloc->resize((size_t)byteSize); + alloc->resize((size_t)count); if(el) - memcpy(alloc->data(), el, (size_t)byteSize); + memcpy(alloc->data(), el, (size_t)count); m_StructuredFile->buffers.push_back(alloc); }