diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-07-15 23:54:05 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2010-07-16 00:02:48 -0700 |
commit | e33348ba54cd68d6936cffd4507037c14d4b10c2 (patch) | |
tree | 1429dd836a48b3f49ee2a27623ff47b5c272c827 /libs/utils | |
parent | bd623daff1f261a0e794f059d90ba5907eb5a89a (diff) | |
download | frameworks_base-e33348ba54cd68d6936cffd4507037c14d4b10c2.zip frameworks_base-e33348ba54cd68d6936cffd4507037c14d4b10c2.tar.gz frameworks_base-e33348ba54cd68d6936cffd4507037c14d4b10c2.tar.bz2 |
Fix bug with phantom input windows.
Add dumpsys integration for the native input dispatcher.
Add some InputDevice API stubs.
Add an appendFormat helper method to String8 for printf style
string formatting mainly for debugging purposes.
Use generic ArrayList<WindowState> everywhere in WindowManagerService
to eliminate unnecessary casts all over.
Change-Id: I9d1e3bd90eb7222d10620200477f11b7bfd25e44
Diffstat (limited to 'libs/utils')
-rw-r--r-- | libs/utils/String8.cpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/libs/utils/String8.cpp b/libs/utils/String8.cpp index 82776f4..1c4f80c 100644 --- a/libs/utils/String8.cpp +++ b/libs/utils/String8.cpp @@ -372,6 +372,27 @@ status_t String8::append(const char* other, size_t otherLen) return real_append(other, otherLen); } +status_t String8::appendFormat(const char* fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + + int result = NO_ERROR; + int n = vsnprintf(NULL, 0, fmt, ap); + if (n != 0) { + size_t oldLength = length(); + char* buf = lockBuffer(oldLength + n); + if (buf) { + vsnprintf(buf + oldLength, n + 1, fmt, ap); + } else { + result = NO_MEMORY; + } + } + + va_end(ap); + return result; +} + status_t String8::real_append(const char* other, size_t otherLen) { const size_t myLen = bytes(); @@ -411,15 +432,16 @@ status_t String8::unlockBuffer(size_t size) if (size != this->size()) { SharedBuffer* buf = SharedBuffer::bufferFromData(mString) ->editResize(size+1); - if (buf) { - char* str = (char*)buf->data(); - str[size] = 0; - mString = str; - return NO_ERROR; + if (! buf) { + return NO_MEMORY; } + + char* str = (char*)buf->data(); + str[size] = 0; + mString = str; } - - return NO_MEMORY; + + return NO_ERROR; } ssize_t String8::find(const char* other, size_t start) const |