summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Moreland2018-03-06 11:11:29 -0600
committerSteven Moreland2018-03-06 11:44:08 -0600
commit241b93cfd3ffadd3e8b4342d8ec869ca197fb575 (patch)
tree2ca32c49d3e9a194272d46dcd25ed267fc48d940 /libutils/String8.cpp
parent1d5b102671ba3cf5da51026328a75012d56f3b98 (diff)
downloadplatform-system-core-241b93cfd3ffadd3e8b4342d8ec869ca197fb575.tar.gz
platform-system-core-241b93cfd3ffadd3e8b4342d8ec869ca197fb575.tar.xz
platform-system-core-241b93cfd3ffadd3e8b4342d8ec869ca197fb575.zip
libutils: Remove Static.cpp and darwin hacks.
Bug: N/A Test: in internal master, the only libraries that reference this symbol are: ./prebuilts/sdk/tools/linux/bin/split-select android::gDarwinIsReallyAnnoying ./prebuilts/sdk/tools/linux/bin/aapt android::gDarwinIsReallyAnnoying ./prebuilts/sdk/tools/linux/bin/aapt2 android::gDarwinIsReallyAnnoying ./prebuilts/sdk/tools/linux/lib64/libaapt2_jni.so android::gDarwinIsReallyAnnoying ./prebuilts/sdk/tools/linux/lib64/libaapt2_jni.so android::gDarwinIsReallyAnnoying + VNDK libraries Test: libutils_test Change-Id: Id39e5ef6438e48fa225ba06dbb59902ca5b60f70
Diffstat (limited to 'libutils/String8.cpp')
-rw-r--r--libutils/String8.cpp40
1 files changed, 8 insertions, 32 deletions
diff --git a/libutils/String8.cpp b/libutils/String8.cpp
index ad0e72ec1..580e870c7 100644
--- a/libutils/String8.cpp
+++ b/libutils/String8.cpp
@@ -40,40 +40,16 @@ namespace android {
40// to OS_PATH_SEPARATOR. 40// to OS_PATH_SEPARATOR.
41#define RES_PATH_SEPARATOR '/' 41#define RES_PATH_SEPARATOR '/'
42 42
43static SharedBuffer* gEmptyStringBuf = NULL; 43static inline char* getEmptyString() {
44static char* gEmptyString = NULL; 44 static SharedBuffer* gEmptyStringBuf = [] {
45 SharedBuffer* buf = SharedBuffer::alloc(1);
46 char* str = static_cast<char*>(buf->data());
47 *str = 0;
48 return buf;
49 }();
45 50
46extern int gDarwinCantLoadAllObjects;
47int gDarwinIsReallyAnnoying;
48
49void initialize_string8();
50
51static inline char* getEmptyString()
52{
53 gEmptyStringBuf->acquire(); 51 gEmptyStringBuf->acquire();
54 return gEmptyString; 52 return static_cast<char*>(gEmptyStringBuf->data());
55}
56
57void initialize_string8()
58{
59 // HACK: This dummy dependency forces linking libutils Static.cpp,
60 // which is needed to initialize String8/String16 classes.
61 // These variables are named for Darwin, but are needed elsewhere too,
62 // including static linking on any platform.
63 gDarwinIsReallyAnnoying = gDarwinCantLoadAllObjects;
64
65 SharedBuffer* buf = SharedBuffer::alloc(1);
66 char* str = (char*)buf->data();
67 *str = 0;
68 gEmptyStringBuf = buf;
69 gEmptyString = str;
70}
71
72void terminate_string8()
73{
74 SharedBuffer::bufferFromData(gEmptyString)->release();
75 gEmptyStringBuf = NULL;
76 gEmptyString = NULL;
77} 53}
78 54
79// --------------------------------------------------------------------------- 55// ---------------------------------------------------------------------------