diff options
author | Mathias Agopian <mathias@google.com> | 2013-08-01 12:47:58 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2013-08-01 12:47:58 -0700 |
commit | ddff6230495b66312ad93f652d0c79069a64dbbd (patch) | |
tree | a14bbab50451c44eac86ca71dedaf6b9c8042fb4 /include/utils | |
parent | 0f10d0abf3e6f6b5631c091256f8b4e7a20a33d0 (diff) | |
download | system_core-ddff6230495b66312ad93f652d0c79069a64dbbd.zip system_core-ddff6230495b66312ad93f652d0c79069a64dbbd.tar.gz system_core-ddff6230495b66312ad93f652d0c79069a64dbbd.tar.bz2 |
minor tweaks to FlattenableUtils
Change-Id: Ibfceec36434baac92c8815a18d902375d3fa1a6d
Diffstat (limited to 'include/utils')
-rw-r--r-- | include/utils/Flattenable.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/include/utils/Flattenable.h b/include/utils/Flattenable.h index c283ad7..882a8b2 100644 --- a/include/utils/Flattenable.h +++ b/include/utils/Flattenable.h @@ -35,13 +35,18 @@ public: } template<int N> - static size_t align(void*& buffer) { + static size_t align(void const*& buffer) { COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); intptr_t b = intptr_t(buffer); buffer = (void*)((intptr_t(buffer) + (N-1)) & ~(N-1)); return size_t(intptr_t(buffer) - b); } + template<int N> + static size_t align(void*& buffer) { + return align<N>( const_cast<void const*&>(buffer) ); + } + static void advance(void*& buffer, size_t& size, size_t offset) { buffer = reinterpret_cast<void*>( intptr_t(buffer) + offset ); size -= offset; @@ -88,8 +93,7 @@ public: // file descriptors are written in the fds[] array but ownership is // not transfered (ie: they must be dupped by the caller of // flatten() if needed). - inline status_t flatten(void*& buffer, size_t& size, - int*& fds, size_t& count) const; + inline status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; // unflattens the object from buffer. // size should be equal to the value of getFlattenedSize() when the @@ -98,8 +102,7 @@ public: // don't need to be dupped(). ie: the caller of unflatten doesn't // keep ownership. If a fd is not retained by unflatten() it must be // explicitly closed. - inline status_t unflatten(void const*& buffer, size_t& size, - int const*& fds, size_t& count); + inline status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); }; template<typename T> |