Fix the mutex diagnostics, and other targets of opportunity.
Three changes for the price of one:
1. Fix the mutex diagnostics so they work right during startup and shutdown.
2. Fix a memory leak in common_test.
3. Fix memory corruption in the compiler; we were calling memset(3) on a struct
with non-POD members.
Thanks, as usual, to valgrind(1) for the latter two (and several bugs in
earlier attempts at the former).
Change-Id: I15e1ffb01e73e4c56a5bbdcaa7233a4b5221e08a
diff --git a/src/mutex.cc b/src/mutex.cc
index b56f1ef..1e30543 100644
--- a/src/mutex.cc
+++ b/src/mutex.cc
@@ -54,20 +54,14 @@
if (rank == -1) {
return;
}
- Thread* self = Thread::Current();
- if (self != NULL) {
- self->CheckSafeToLockOrUnlock(rank, is_locking);
- }
+ Thread::Current()->CheckSafeToLockOrUnlock(rank, is_locking);
}
static inline void CheckSafeToWait(MutexRank rank) {
if (!kIsDebugBuild) {
return;
}
- Thread* self = Thread::Current();
- if (self != NULL) {
- self->CheckSafeToWait(rank);
- }
+ Thread::Current()->CheckSafeToWait(rank);
}
Mutex::Mutex(const char* name, MutexRank rank) : name_(name), rank_(rank) {