[Lldb-commits] [lldb] r177615 - Simplify the logic for DNBDataRef::ValidOffsetForDataOfSize() and DNBDataRef::ValidOffset() functions.
Greg Clayton
gclayton at apple.com
Wed Mar 20 17:24:59 PDT 2013
Author: gclayton
Date: Wed Mar 20 19:24:59 2013
New Revision: 177615
URL: http://llvm.org/viewvc/llvm-project?rev=177615&view=rev
Log:
Simplify the logic for DNBDataRef::ValidOffsetForDataOfSize() and DNBDataRef::ValidOffset() functions.
Modified:
lldb/trunk/tools/debugserver/source/DNBDataRef.h
Modified: lldb/trunk/tools/debugserver/source/DNBDataRef.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBDataRef.h?rev=177615&r1=177614&r2=177615&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNBDataRef.h (original)
+++ lldb/trunk/tools/debugserver/source/DNBDataRef.h Wed Mar 20 19:24:59 2013
@@ -56,8 +56,22 @@ public:
m_swap = false;
}
- bool ValidOffset(offset_t offset) const { return (m_start < m_end) && ((uint32_t)(m_end - m_start) > offset); }
- bool ValidOffsetForDataOfSize(offset_t offset, uint32_t num_bytes) const { return (m_start < m_end) && ((uint32_t)(m_end - m_start) > (offset + ((num_bytes > 0) ? (num_bytes - 1) : 0))); }
+ offset_t BytesLeft (offset_t offset) const
+ {
+ const offset_t size = GetSize();
+ if (size > offset)
+ return size - offset;
+ return 0;
+ }
+
+ bool ValidOffset(offset_t offset) const
+ {
+ return BytesLeft(offset) > 0;
+ }
+ bool ValidOffsetForDataOfSize(offset_t offset, uint32_t num_bytes) const
+ {
+ return num_bytes <= BytesLeft (offset);
+ }
size_t GetSize() const { return m_end - m_start; }
const uint8_t * GetDataStart() const { return m_start; }
const uint8_t * GetDataEnd() const { return m_end; }
More information about the lldb-commits
mailing list