diff options
| author | Alex Sakhartchouk <alexst@google.com> | 2010-11-09 17:00:54 -0800 |
|---|---|---|
| committer | Alex Sakhartchouk <alexst@google.com> | 2010-11-10 11:30:51 -0800 |
| commit | afb743aca56c18beb7ab924e75cb6e070ef3e55a (patch) | |
| tree | 9c2683d418230dd7cb53e667cdd876e617bb3d27 /rsStream.cpp | |
| parent | b60d757354880b6a711840eb35cc381cf7172246 (diff) | |
Code cleanup to make formatting consistent
across all the renderscript files.
Change-Id: Idf5fcc60877e44c8f074f7176e37f70b3b895a3c
Diffstat (limited to 'rsStream.cpp')
| -rw-r--r-- | rsStream.cpp | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/rsStream.cpp b/rsStream.cpp index 68241fa4..49ed567d 100644 --- a/rsStream.cpp +++ b/rsStream.cpp @@ -26,21 +26,18 @@ using namespace android; using namespace android::renderscript; -IStream::IStream(const uint8_t *buf, bool use64) -{ +IStream::IStream(const uint8_t *buf, bool use64) { mData = buf; mPos = 0; mUse64 = use64; } -void IStream::loadByteArray(void *dest, size_t numBytes) -{ +void IStream::loadByteArray(void *dest, size_t numBytes) { memcpy(dest, mData + mPos, numBytes); mPos += numBytes; } -uint64_t IStream::loadOffset() -{ +uint64_t IStream::loadOffset() { uint64_t tmp; if (mUse64) { mPos = (mPos + 7) & (~7); @@ -51,44 +48,37 @@ uint64_t IStream::loadOffset() return loadU32(); } -void IStream::loadString(String8 *s) -{ +void IStream::loadString(String8 *s) { uint32_t len = loadU32(); s->setTo((const char *)&mData[mPos], len); mPos += len; } - // Output stream implementation - -OStream::OStream(uint64_t len, bool use64) -{ +OStream::OStream(uint64_t len, bool use64) { mData = (uint8_t*)malloc(len); mLength = len; mPos = 0; mUse64 = use64; } -OStream::~OStream() -{ +OStream::~OStream() { free(mData); } -void OStream::addByteArray(const void *src, size_t numBytes) -{ +void OStream::addByteArray(const void *src, size_t numBytes) { // We need to potentially grow more than once if the number of byes we write is substantial - while(mPos + numBytes >= mLength) { + while (mPos + numBytes >= mLength) { growSize(); } memcpy(mData + mPos, src, numBytes); mPos += numBytes; } -void OStream::addOffset(uint64_t v) -{ +void OStream::addOffset(uint64_t v) { if (mUse64) { mPos = (mPos + 7) & (~7); - if(mPos + sizeof(v) >= mLength) { + if (mPos + sizeof(v) >= mLength) { growSize(); } mData[mPos++] = (uint8_t)(v & 0xff); @@ -99,28 +89,25 @@ void OStream::addOffset(uint64_t v) mData[mPos++] = (uint8_t)((v >> 40) & 0xff); mData[mPos++] = (uint8_t)((v >> 48) & 0xff); mData[mPos++] = (uint8_t)((v >> 56) & 0xff); - } - else { + } else { addU32(v); } } -void OStream::addString(String8 *s) -{ +void OStream::addString(String8 *s) { uint32_t len = s->size(); addU32(len); - if(mPos + len*sizeof(char) >= mLength) { + if (mPos + len*sizeof(char) >= mLength) { growSize(); } char *stringData = reinterpret_cast<char *>(&mData[mPos]); - for(uint32_t i = 0; i < len; i ++) { + for (uint32_t i = 0; i < len; i ++) { stringData[i] = s->string()[i]; } mPos += len*sizeof(char); } -void OStream::growSize() -{ +void OStream::growSize() { uint8_t *newData = (uint8_t*)malloc(mLength*2); memcpy(newData, mData, mLength*sizeof(uint8_t)); mLength = mLength * 2; |
