am eec69d29: Merge "Fix bug with phantom input windows." into gingerbread
Merge commit 'eec69d2923636b2aaa51df93bacc2b3bbb742736' into gingerbread-plus-aosp * commit 'eec69d2923636b2aaa51df93bacc2b3bbb742736': Fix bug with phantom input windows.
This commit is contained in:
commit
e2cefe54f4
@ -171,6 +171,8 @@ public:
|
|||||||
status_t append(const char* other);
|
status_t append(const char* other);
|
||||||
status_t append(const char* other, size_t numChars);
|
status_t append(const char* other, size_t numChars);
|
||||||
|
|
||||||
|
status_t appendFormat(const char* fmt, ...);
|
||||||
|
|
||||||
// Note that this function takes O(N) time to calculate the value.
|
// Note that this function takes O(N) time to calculate the value.
|
||||||
// No cache value is stored.
|
// No cache value is stored.
|
||||||
size_t getUtf32Length() const;
|
size_t getUtf32Length() const;
|
||||||
|
@ -372,6 +372,27 @@ status_t String8::append(const char* other, size_t otherLen)
|
|||||||
return real_append(other, 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)
|
status_t String8::real_append(const char* other, size_t otherLen)
|
||||||
{
|
{
|
||||||
const size_t myLen = bytes();
|
const size_t myLen = bytes();
|
||||||
@ -411,15 +432,16 @@ status_t String8::unlockBuffer(size_t size)
|
|||||||
if (size != this->size()) {
|
if (size != this->size()) {
|
||||||
SharedBuffer* buf = SharedBuffer::bufferFromData(mString)
|
SharedBuffer* buf = SharedBuffer::bufferFromData(mString)
|
||||||
->editResize(size+1);
|
->editResize(size+1);
|
||||||
if (buf) {
|
if (! buf) {
|
||||||
|
return NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
char* str = (char*)buf->data();
|
char* str = (char*)buf->data();
|
||||||
str[size] = 0;
|
str[size] = 0;
|
||||||
mString = str;
|
mString = str;
|
||||||
return NO_ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_MEMORY;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t String8::find(const char* other, size_t start) const
|
ssize_t String8::find(const char* other, size_t start) const
|
||||||
|
Loading…
Reference in New Issue
Block a user