minor tweaks to FlattenableUtils

Change-Id: Ibfceec36434baac92c8815a18d902375d3fa1a6d
This commit is contained in:
Mathias Agopian 2013-08-01 12:47:58 -07:00
parent 0f10d0abf3
commit ddff623049
1 changed files with 8 additions and 5 deletions

View File

@ -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>