summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/utils/BasicHashtable.h9
-rw-r--r--include/utils/String16.h16
-rw-r--r--include/utils/String8.h18
-rw-r--r--libutils/BasicHashtable.cpp8
-rw-r--r--libutils/SharedBuffer.cpp3
-rw-r--r--libutils/SharedBuffer.h (renamed from include/utils/SharedBuffer.h)0
-rw-r--r--libutils/String16.cpp11
-rw-r--r--libutils/String8.cpp13
-rw-r--r--libutils/VectorImpl.cpp3
9 files changed, 43 insertions, 38 deletions
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 @@
19 19
20#include <stdint.h> 20#include <stdint.h>
21#include <sys/types.h> 21#include <sys/types.h>
22#include <utils/SharedBuffer.h>
23#include <utils/TypeHelpers.h> 22#include <utils/TypeHelpers.h>
24 23
25namespace android { 24namespace android {
@@ -55,13 +54,7 @@ protected:
55 virtual ~BasicHashtableImpl(); 54 virtual ~BasicHashtableImpl();
56 55
57 void dispose(); 56 void dispose();
58 57 void edit();
59 inline void edit() {
60 if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) {
61 clone();
62 }
63 }
64
65 void setTo(const BasicHashtableImpl& other); 58 void setTo(const BasicHashtableImpl& other);
66 void clear(); 59 void clear();
67 60
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 @@
18#define ANDROID_STRING16_H 18#define ANDROID_STRING16_H
19 19
20#include <utils/Errors.h> 20#include <utils/Errors.h>
21#include <utils/SharedBuffer.h>
22#include <utils/Unicode.h> 21#include <utils/Unicode.h>
23#include <utils/TypeHelpers.h> 22#include <utils/TypeHelpers.h>
24 23
@@ -34,6 +33,7 @@ namespace android {
34 33
35// --------------------------------------------------------------------------- 34// ---------------------------------------------------------------------------
36 35
36class SharedBuffer;
37class String8; 37class String8;
38class TextOutput; 38class TextOutput;
39 39
@@ -64,10 +64,10 @@ public:
64 ~String16(); 64 ~String16();
65 65
66 inline const char16_t* string() const; 66 inline const char16_t* string() const;
67 inline size_t size() const;
68 67
69 inline const SharedBuffer* sharedBuffer() const; 68 const SharedBuffer* sharedBuffer() const;
70 69
70 size_t size() const;
71 void setTo(const String16& other); 71 void setTo(const String16& other);
72 status_t setTo(const char16_t* other); 72 status_t setTo(const char16_t* other);
73 status_t setTo(const char16_t* other, size_t len); 73 status_t setTo(const char16_t* other, size_t len);
@@ -144,16 +144,6 @@ inline const char16_t* String16::string() const
144 return mString; 144 return mString;
145} 145}
146 146
147inline size_t String16::size() const
148{
149 return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1;
150}
151
152inline const SharedBuffer* String16::sharedBuffer() const
153{
154 return SharedBuffer::bufferFromData(mString);
155}
156
157inline String16& String16::operator=(const String16& other) 147inline String16& String16::operator=(const String16& other)
158{ 148{
159 setTo(other); 149 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 @@
18#define ANDROID_STRING8_H 18#define ANDROID_STRING8_H
19 19
20#include <utils/Errors.h> 20#include <utils/Errors.h>
21#include <utils/SharedBuffer.h>
22#include <utils/Unicode.h> 21#include <utils/Unicode.h>
23#include <utils/TypeHelpers.h> 22#include <utils/TypeHelpers.h>
24 23
@@ -29,6 +28,7 @@
29 28
30namespace android { 29namespace android {
31 30
31class SharedBuffer;
32class String16; 32class String16;
33class TextOutput; 33class TextOutput;
34 34
@@ -65,11 +65,11 @@ public:
65 65
66 inline const char* string() const; 66 inline const char* string() const;
67 inline size_t size() const; 67 inline size_t size() const;
68 inline size_t length() const;
69 inline size_t bytes() const; 68 inline size_t bytes() const;
70 inline bool isEmpty() const; 69 inline bool isEmpty() const;
71 70
72 inline const SharedBuffer* sharedBuffer() const; 71 size_t length() const;
72 const SharedBuffer* sharedBuffer() const;
73 73
74 void clear(); 74 void clear();
75 75
@@ -263,11 +263,6 @@ inline const char* String8::string() const
263 return mString; 263 return mString;
264} 264}
265 265
266inline size_t String8::length() const
267{
268 return SharedBuffer::sizeFromData(mString)-1;
269}
270
271inline size_t String8::size() const 266inline size_t String8::size() const
272{ 267{
273 return length(); 268 return length();
@@ -280,12 +275,7 @@ inline bool String8::isEmpty() const
280 275
281inline size_t String8::bytes() const 276inline size_t String8::bytes() const
282{ 277{
283 return SharedBuffer::sizeFromData(mString)-1; 278 return length();
284}
285
286inline const SharedBuffer* String8::sharedBuffer() const
287{
288 return SharedBuffer::bufferFromData(mString);
289} 279}
290 280
291inline bool String8::contains(const char* other) const 281inline 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 @@
22#include <utils/BasicHashtable.h> 22#include <utils/BasicHashtable.h>
23#include <utils/misc.h> 23#include <utils/misc.h>
24 24
25#include "SharedBuffer.h"
26
25namespace android { 27namespace android {
26 28
27BasicHashtableImpl::BasicHashtableImpl(size_t entrySize, bool hasTrivialDestructor, 29BasicHashtableImpl::BasicHashtableImpl(size_t entrySize, bool hasTrivialDestructor,
@@ -46,6 +48,12 @@ BasicHashtableImpl::~BasicHashtableImpl()
46{ 48{
47} 49}
48 50
51void BasicHashtableImpl::edit() {
52 if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) {
53 clone();
54 }
55}
56
49void BasicHashtableImpl::dispose() { 57void BasicHashtableImpl::dispose() {
50 if (mBuckets) { 58 if (mBuckets) {
51 releaseBuckets(mBuckets, mBucketCount); 59 releaseBuckets(mBuckets, mBucketCount);
diff --git a/libutils/SharedBuffer.cpp b/libutils/SharedBuffer.cpp
index 947551a6a..c7dd1ab34 100644
--- a/libutils/SharedBuffer.cpp
+++ b/libutils/SharedBuffer.cpp
@@ -20,9 +20,10 @@
20#include <string.h> 20#include <string.h>
21 21
22#include <log/log.h> 22#include <log/log.h>
23#include <utils/SharedBuffer.h>
24#include <utils/Atomic.h> 23#include <utils/Atomic.h>
25 24
25#include "SharedBuffer.h"
26
26// --------------------------------------------------------------------------- 27// ---------------------------------------------------------------------------
27 28
28namespace android { 29namespace android {
diff --git a/include/utils/SharedBuffer.h b/libutils/SharedBuffer.h
index b6709537e..b6709537e 100644
--- a/include/utils/SharedBuffer.h
+++ b/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 @@
25#include <stdio.h> 25#include <stdio.h>
26#include <ctype.h> 26#include <ctype.h>
27 27
28#include "SharedBuffer.h"
28 29
29namespace android { 30namespace android {
30 31
@@ -165,6 +166,16 @@ String16::~String16()
165 SharedBuffer::bufferFromData(mString)->release(); 166 SharedBuffer::bufferFromData(mString)->release();
166} 167}
167 168
169size_t String16::size() const
170{
171 return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1;
172}
173
174const SharedBuffer* String16::sharedBuffer() const
175{
176 return SharedBuffer::bufferFromData(mString);
177}
178
168void String16::setTo(const String16& other) 179void String16::setTo(const String16& other)
169{ 180{
170 SharedBuffer::bufferFromData(other.mString)->acquire(); 181 SharedBuffer::bufferFromData(other.mString)->acquire();
diff --git a/libutils/String8.cpp b/libutils/String8.cpp
index 2d0602357..4fca2c119 100644
--- a/libutils/String8.cpp
+++ b/libutils/String8.cpp
@@ -22,12 +22,13 @@
22#include <utils/Compat.h> 22#include <utils/Compat.h>
23#include <utils/Log.h> 23#include <utils/Log.h>
24#include <utils/Unicode.h> 24#include <utils/Unicode.h>
25#include <utils/SharedBuffer.h>
26#include <utils/String16.h> 25#include <utils/String16.h>
27#include <utils/threads.h> 26#include <utils/threads.h>
28 27
29#include <ctype.h> 28#include <ctype.h>
30 29
30#include "SharedBuffer.h"
31
31/* 32/*
32 * Functions outside android is below the namespace android, since they use 33 * Functions outside android is below the namespace android, since they use
33 * functions and constants in android namespace. 34 * functions and constants in android namespace.
@@ -214,6 +215,16 @@ String8::~String8()
214 SharedBuffer::bufferFromData(mString)->release(); 215 SharedBuffer::bufferFromData(mString)->release();
215} 216}
216 217
218size_t String8::length() const
219{
220 return SharedBuffer::sizeFromData(mString)-1;
221}
222
223const SharedBuffer* String8::sharedBuffer() const
224{
225 return SharedBuffer::bufferFromData(mString);
226}
227
217String8 String8::format(const char* fmt, ...) 228String8 String8::format(const char* fmt, ...)
218{ 229{
219 va_list args; 230 va_list args;
diff --git a/libutils/VectorImpl.cpp b/libutils/VectorImpl.cpp
index 7c5347299..e8d40ed20 100644
--- a/libutils/VectorImpl.cpp
+++ b/libutils/VectorImpl.cpp
@@ -24,9 +24,10 @@
24#include <safe_iop.h> 24#include <safe_iop.h>
25 25
26#include <utils/Errors.h> 26#include <utils/Errors.h>
27#include <utils/SharedBuffer.h>
28#include <utils/VectorImpl.h> 27#include <utils/VectorImpl.h>
29 28
29#include "SharedBuffer.h"
30
30/*****************************************************************************/ 31/*****************************************************************************/
31 32
32 33