summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2009-10-28 23:42:25 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-10-28 23:42:25 -0700
commit9e8ae3dfbea2ef8f07a2e1b4ade62291a737a0ca (patch)
treec37107baff7a35b2c59cb144705441c0b01457ca /media
parentbaf683293d26ead0d530a1c8d30b3821712fcdf2 (diff)
parentb1a8f54bf62c3974831bf3c866275425127cf7b6 (diff)
downloadframeworks_base-9e8ae3dfbea2ef8f07a2e1b4ade62291a737a0ca.zip
frameworks_base-9e8ae3dfbea2ef8f07a2e1b4ade62291a737a0ca.tar.gz
frameworks_base-9e8ae3dfbea2ef8f07a2e1b4ade62291a737a0ca.tar.bz2
am b1a8f54b: am 27123468: Use a simple replacement for String8 that allocates its storage beforehand to avoid reentering the heap while we\'re examining it (leak checker).
Merge commit 'b1a8f54bf62c3974831bf3c866275425127cf7b6' * commit 'b1a8f54bf62c3974831bf3c866275425127cf7b6': Use a simple replacement for String8 that allocates its storage beforehand to avoid reentering the heap while we're examining it (leak checker).
Diffstat (limited to 'media')
-rw-r--r--media/libmediaplayerservice/MediaPlayerService.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index ab759df..64267de 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -356,11 +356,44 @@ extern "C" void get_malloc_leak_info(uint8_t** info, size_t* overallSize,
size_t* infoSize, size_t* totalMemory, size_t* backtraceSize);
extern "C" void free_malloc_leak_info(uint8_t* info);
+// Use the String-class below instead of String8 to allocate all memory
+// beforehand and not reenter the heap while we are examining it...
+struct MyString8 {
+ static const size_t MAX_SIZE = 256 * 1024;
+
+ MyString8()
+ : mPtr((char *)malloc(MAX_SIZE)) {
+ *mPtr = '\0';
+ }
+
+ ~MyString8() {
+ free(mPtr);
+ }
+
+ void append(const char *s) {
+ strcat(mPtr, s);
+ }
+
+ const char *string() const {
+ return mPtr;
+ }
+
+ size_t size() const {
+ return strlen(mPtr);
+ }
+
+private:
+ char *mPtr;
+
+ MyString8(const MyString8 &);
+ MyString8 &operator=(const MyString8 &);
+};
+
void memStatus(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
- String8 result;
+ MyString8 result;
typedef struct {
size_t size;