Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6d39eb9d authored by Oscar Rydhé's avatar Oscar Rydhé Committed by Takeshi Aimi
Browse files

Do partial reads in MemoryLeakTrackUtil

Do partial read in MemoryLeakTrackUtil dumpMemoryAddresses
to avoid using more memory than what is allocated.

Change-Id: I94feb4e00647407f938571167b981c7371f39e3d
parent 96a7b5a9
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ struct MyString8 {
    }

    void append(const char *s) {
        strcat(mPtr, s);
        strncat(mPtr, s, MAX_SIZE - size() - 1);
    }

    const char *string() const {
@@ -60,6 +60,10 @@ struct MyString8 {
        return strlen(mPtr);
    }

    void clear() {
        *mPtr = '\0';
    }

private:
    char *mPtr;

@@ -139,6 +143,9 @@ void dumpMemoryAddresses(int fd)
            }
        } while (moved);

        write(fd, result.string(), result.size());
        result.clear();

        for (size_t i = 0; i < count; i++) {
            AllocEntry *e = &entries[i];

@@ -152,13 +159,14 @@ void dumpMemoryAddresses(int fd)
                result.append(buffer);
            }
            result.append("\n");

            write(fd, result.string(), result.size());
            result.clear();
        }

        delete[] entries;
        free_malloc_leak_info(info);
    }

    write(fd, result.string(), result.size());
}

#else