diff options
author | Mathias Agopian <mathias@google.com> | 2012-08-31 16:20:23 -0700 |
---|---|---|
committer | Alex Ray <aray@google.com> | 2013-07-30 13:57:00 -0700 |
commit | e79aadd143a6467d70969e3cd4cb31a1623870f3 (patch) | |
tree | 8869b912837707abff1f024dcccfdc972692d7d7 /include | |
parent | 919fa297fe54d16e202752bd91a0a99ff59bef0d (diff) | |
download | system_core-e79aadd143a6467d70969e3cd4cb31a1623870f3.zip system_core-e79aadd143a6467d70969e3cd4cb31a1623870f3.tar.gz system_core-e79aadd143a6467d70969e3cd4cb31a1623870f3.tar.bz2 |
minor SharedBuffer clean-up
Change-Id: If38b7ce85806ae628c00f2c938de4e3f75142543
Diffstat (limited to 'include')
-rw-r--r-- | include/utils/SharedBuffer.h | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/include/utils/SharedBuffer.h b/include/utils/SharedBuffer.h index 1d6d497..b670953 100644 --- a/include/utils/SharedBuffer.h +++ b/include/utils/SharedBuffer.h @@ -44,9 +44,6 @@ public: * users. */ static ssize_t dealloc(const SharedBuffer* released); - - //! get the SharedBuffer from the data pointer - static inline const SharedBuffer* sharedBuffer(const void* data); //! access the data for read inline const void* data() const; @@ -94,7 +91,8 @@ public: private: inline SharedBuffer() { } inline ~SharedBuffer() { } - inline SharedBuffer(const SharedBuffer&); + SharedBuffer(const SharedBuffer&); + SharedBuffer& operator = (const SharedBuffer&); // 16 bytes. must be sized to preserve correct alignment. mutable int32_t mRefs; @@ -104,10 +102,6 @@ private: // --------------------------------------------------------------------------- -const SharedBuffer* SharedBuffer::sharedBuffer(const void* data) { - return data ? reinterpret_cast<const SharedBuffer *>(data)-1 : 0; -} - const void* SharedBuffer::data() const { return this + 1; } @@ -120,19 +114,16 @@ size_t SharedBuffer::size() const { return mSize; } -SharedBuffer* SharedBuffer::bufferFromData(void* data) -{ - return ((SharedBuffer*)data)-1; +SharedBuffer* SharedBuffer::bufferFromData(void* data) { + return data ? static_cast<SharedBuffer *>(data)-1 : 0; } -const SharedBuffer* SharedBuffer::bufferFromData(const void* data) -{ - return ((const SharedBuffer*)data)-1; +const SharedBuffer* SharedBuffer::bufferFromData(const void* data) { + return data ? static_cast<const SharedBuffer *>(data)-1 : 0; } -size_t SharedBuffer::sizeFromData(const void* data) -{ - return (((const SharedBuffer*)data)-1)->mSize; +size_t SharedBuffer::sizeFromData(const void* data) { + return data ? bufferFromData(data)->mSize : 0; } bool SharedBuffer::onlyOwner() const { |