Merge "String8: ensure static init done prior to empty string reference"

This commit is contained in:
Todd Poynor 2013-05-07 23:30:21 +00:00 committed by Android (Google) Code Review
commit b4f1a027cb

View File

@ -48,12 +48,16 @@ int gDarwinIsReallyAnnoying;
static inline char* getEmptyString() static inline char* getEmptyString()
{ {
if (!gEmptyStringBuf) initialize_string8();
gEmptyStringBuf->acquire(); gEmptyStringBuf->acquire();
return gEmptyString; return gEmptyString;
} }
void initialize_string8() void initialize_string8()
{ {
if (gEmptyStringBuf) return;
// HACK: This dummy dependency forces linking libutils Static.cpp, // HACK: This dummy dependency forces linking libutils Static.cpp,
// which is needed to initialize String8/String16 classes. // which is needed to initialize String8/String16 classes.
// These variables are named for Darwin, but are needed elsewhere too, // These variables are named for Darwin, but are needed elsewhere too,