diff --git a/include/utils/BasicHashtable.h b/include/utils/BasicHashtable.h index c235d6252..cf4705954 100644 --- a/include/utils/BasicHashtable.h +++ b/include/utils/BasicHashtable.h @@ -19,7 +19,6 @@ #include #include -#include #include namespace android { @@ -55,13 +54,7 @@ protected: virtual ~BasicHashtableImpl(); void dispose(); - - inline void edit() { - if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) { - clone(); - } - } - + void edit(); void setTo(const BasicHashtableImpl& other); void clear(); diff --git a/include/utils/String16.h b/include/utils/String16.h index d131bfc6a..b2ab5dc11 100644 --- a/include/utils/String16.h +++ b/include/utils/String16.h @@ -18,7 +18,6 @@ #define ANDROID_STRING16_H #include -#include #include #include @@ -34,6 +33,7 @@ namespace android { // --------------------------------------------------------------------------- +class SharedBuffer; class String8; class TextOutput; @@ -64,10 +64,10 @@ public: ~String16(); inline const char16_t* string() const; - inline size_t size() const; - inline const SharedBuffer* sharedBuffer() const; + const SharedBuffer* sharedBuffer() const; + size_t size() const; void setTo(const String16& other); status_t setTo(const char16_t* other); status_t setTo(const char16_t* other, size_t len); @@ -144,16 +144,6 @@ inline const char16_t* String16::string() const return mString; } -inline size_t String16::size() const -{ - return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1; -} - -inline const SharedBuffer* String16::sharedBuffer() const -{ - return SharedBuffer::bufferFromData(mString); -} - inline String16& String16::operator=(const String16& other) { setTo(other); diff --git a/include/utils/String8.h b/include/utils/String8.h index ecfcf10be..a8a37db21 100644 --- a/include/utils/String8.h +++ b/include/utils/String8.h @@ -18,7 +18,6 @@ #define ANDROID_STRING8_H #include -#include #include #include @@ -29,6 +28,7 @@ namespace android { +class SharedBuffer; class String16; class TextOutput; @@ -65,11 +65,11 @@ public: inline const char* string() const; inline size_t size() const; - inline size_t length() const; inline size_t bytes() const; inline bool isEmpty() const; - inline const SharedBuffer* sharedBuffer() const; + size_t length() const; + const SharedBuffer* sharedBuffer() const; void clear(); @@ -263,11 +263,6 @@ inline const char* String8::string() const return mString; } -inline size_t String8::length() const -{ - return SharedBuffer::sizeFromData(mString)-1; -} - inline size_t String8::size() const { return length(); @@ -280,12 +275,7 @@ inline bool String8::isEmpty() const inline size_t String8::bytes() const { - return SharedBuffer::sizeFromData(mString)-1; -} - -inline const SharedBuffer* String8::sharedBuffer() const -{ - return SharedBuffer::bufferFromData(mString); + return length(); } inline bool String8::contains(const char* other) const diff --git a/libutils/BasicHashtable.cpp b/libutils/BasicHashtable.cpp index 491d9e98b..1e9f05333 100644 --- a/libutils/BasicHashtable.cpp +++ b/libutils/BasicHashtable.cpp @@ -22,6 +22,8 @@ #include #include +#include "SharedBuffer.h" + namespace android { BasicHashtableImpl::BasicHashtableImpl(size_t entrySize, bool hasTrivialDestructor, @@ -46,6 +48,12 @@ BasicHashtableImpl::~BasicHashtableImpl() { } +void BasicHashtableImpl::edit() { + if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) { + clone(); + } +} + void BasicHashtableImpl::dispose() { if (mBuckets) { releaseBuckets(mBuckets, mBucketCount); diff --git a/libutils/SharedBuffer.cpp b/libutils/SharedBuffer.cpp index 3555fb712..003e38697 100644 --- a/libutils/SharedBuffer.cpp +++ b/libutils/SharedBuffer.cpp @@ -17,9 +17,10 @@ #include #include -#include #include +#include "SharedBuffer.h" + // --------------------------------------------------------------------------- namespace android { diff --git a/include/utils/SharedBuffer.h b/libutils/SharedBuffer.h similarity index 100% rename from include/utils/SharedBuffer.h rename to libutils/SharedBuffer.h diff --git a/libutils/String16.cpp b/libutils/String16.cpp index 91efdaa39..67be9d8fa 100644 --- a/libutils/String16.cpp +++ b/libutils/String16.cpp @@ -25,6 +25,7 @@ #include #include +#include "SharedBuffer.h" namespace android { @@ -165,6 +166,16 @@ String16::~String16() SharedBuffer::bufferFromData(mString)->release(); } +size_t String16::size() const +{ + return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1; +} + +const SharedBuffer* String16::sharedBuffer() const +{ + return SharedBuffer::bufferFromData(mString); +} + void String16::setTo(const String16& other) { SharedBuffer::bufferFromData(other.mString)->acquire(); diff --git a/libutils/String8.cpp b/libutils/String8.cpp index 69313ead7..5e8552049 100644 --- a/libutils/String8.cpp +++ b/libutils/String8.cpp @@ -19,12 +19,13 @@ #include #include #include -#include #include #include #include +#include "SharedBuffer.h" + /* * Functions outside android is below the namespace android, since they use * functions and constants in android namespace. @@ -211,6 +212,16 @@ String8::~String8() SharedBuffer::bufferFromData(mString)->release(); } +size_t String8::length() const +{ + return SharedBuffer::sizeFromData(mString)-1; +} + +const SharedBuffer* String8::sharedBuffer() const +{ + return SharedBuffer::bufferFromData(mString); +} + String8 String8::format(const char* fmt, ...) { va_list args; diff --git a/libutils/VectorImpl.cpp b/libutils/VectorImpl.cpp index 2f770f590..2ac158b9f 100644 --- a/libutils/VectorImpl.cpp +++ b/libutils/VectorImpl.cpp @@ -23,9 +23,10 @@ #include #include -#include #include +#include "SharedBuffer.h" + /*****************************************************************************/