aboutsummaryrefslogtreecommitdiff
path: root/src/client/ios/Breakpad.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/ios/Breakpad.mm')
-rw-r--r--src/client/ios/Breakpad.mm29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm
index c46509e8..3b9f6d3f 100644
--- a/src/client/ios/Breakpad.mm
+++ b/src/client/ios/Breakpad.mm
@@ -31,6 +31,7 @@
#import "client/ios/Breakpad.h"
+#include <assert.h>
#import <Foundation/Foundation.h>
#include <pthread.h>
#include <sys/stat.h>
@@ -91,36 +92,32 @@ pthread_mutex_t gDictionaryMutex;
// ProtectedMemoryLocker will unprotect this block after taking the lock.
// Its destructor will first re-protect the memory then release the lock.
class ProtectedMemoryLocker {
-public:
- // allocator may be NULL, in which case no Protect() or Unprotect() calls
- // will be made, but a lock will still be taken
+ public:
ProtectedMemoryLocker(pthread_mutex_t *mutex,
ProtectedMemoryAllocator *allocator)
- : mutex_(mutex), allocator_(allocator) {
+ : mutex_(mutex),
+ allocator_(allocator) {
// Lock the mutex
- assert(pthread_mutex_lock(mutex_) == 0);
+ int rv = pthread_mutex_lock(mutex_);
+ assert(rv == 0);
// Unprotect the memory
- if (allocator_ ) {
- allocator_->Unprotect();
- }
+ allocator_->Unprotect();
}
~ProtectedMemoryLocker() {
// First protect the memory
- if (allocator_) {
- allocator_->Protect();
- }
+ allocator_->Protect();
// Then unlock the mutex
- assert(pthread_mutex_unlock(mutex_) == 0);
+ int rv = pthread_mutex_unlock(mutex_);
+ assert(rv == 0);
};
-private:
- // Keep anybody from ever creating one of these things not on the stack.
- ProtectedMemoryLocker() { }
+ private:
+ ProtectedMemoryLocker();
ProtectedMemoryLocker(const ProtectedMemoryLocker&);
- ProtectedMemoryLocker & operator=(ProtectedMemoryLocker&);
+ ProtectedMemoryLocker& operator=(const ProtectedMemoryLocker&);
pthread_mutex_t *mutex_;
ProtectedMemoryAllocator *allocator_;