Match argument order in cpp file
We swap the 2nd and 3rd arguments to the CallocEntry constructor
to match the order in the cpp file, and match the C calloc convention.
We also fix an invocation of this constructor.
Change-Id: Iebe16d82a74459e5e957c1d9e2cc1aebb15150d0
Test: TreeHugger
diff --git a/libc/malloc_debug/RecordData.h b/libc/malloc_debug/RecordData.h
index 484d73b..a02c956 100644
--- a/libc/malloc_debug/RecordData.h
+++ b/libc/malloc_debug/RecordData.h
@@ -109,7 +109,7 @@
class CallocEntry : public MallocEntry {
public:
- CallocEntry(void* pointer, size_t size, size_t nmemb, uint64_t st, uint64_t et);
+ CallocEntry(void* pointer, size_t nmemb, size_t size, uint64_t st, uint64_t et);
virtual ~CallocEntry() = default;
bool Write(int fd) const override;
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 7c68242..4bc5649 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -943,7 +943,7 @@
if (g_debug->config().options() & RECORD_ALLOCS) {
g_debug->record->AddEntry(
- new CallocEntry(pointer, bytes, nmemb, result.GetStartTimeNS(), result.GetEndTimeNS()));
+ new CallocEntry(pointer, nmemb, bytes, result.GetStartTimeNS(), result.GetEndTimeNS()));
}
if (pointer != nullptr && g_debug->TrackPointers()) {
diff --git a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
index 6215379..bf3ed14 100644
--- a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
@@ -2196,7 +2196,7 @@
debug_free(pointer);
expected.push_back(android::base::StringPrintf("%d: free %p", getpid(), pointer));
- pointer = debug_calloc(1, 20);
+ pointer = debug_calloc(20, 1);
ASSERT_TRUE(pointer != nullptr);
expected.push_back(android::base::StringPrintf("%d: calloc %p 20 1", getpid(), pointer));
debug_free(pointer);