Allow building with -pedantic (#186). r=ted.mielczarek

http://groups.google.com/group/google-breakpad-dev/browse_thread/thread/6aa39d7f0ffa3c42


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@183 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
mmentovai 2007-05-31 19:44:52 +00:00
parent e96a791d9a
commit 2e0e2234b9
12 changed files with 193 additions and 63 deletions

View file

@ -37,26 +37,27 @@
#include <assert.h>
#include "client/minidump_file_writer.h"
#include "google_breakpad/common/minidump_size.h"
namespace google_breakpad {
template<typename MDType>
inline bool TypedMDRVA<MDType>::Allocate() {
allocation_state_ = SINGLE_OBJECT;
return UntypedMDRVA::Allocate(sizeof(MDType));
return UntypedMDRVA::Allocate(minidump_size<MDType>::size());
}
template<typename MDType>
inline bool TypedMDRVA<MDType>::Allocate(size_t additional) {
allocation_state_ = SINGLE_OBJECT;
return UntypedMDRVA::Allocate(sizeof(MDType) + additional);
return UntypedMDRVA::Allocate(minidump_size<MDType>::size() + additional);
}
template<typename MDType>
inline bool TypedMDRVA<MDType>::AllocateArray(size_t count) {
assert(count);
allocation_state_ = ARRAY;
return UntypedMDRVA::Allocate(sizeof(MDType) * count);
return UntypedMDRVA::Allocate(minidump_size<MDType>::size() * count);
}
template<typename MDType>
@ -64,14 +65,14 @@ inline bool TypedMDRVA<MDType>::AllocateObjectAndArray(unsigned int count,
size_t size) {
assert(count && size);
allocation_state_ = SINGLE_OBJECT_WITH_ARRAY;
return UntypedMDRVA::Allocate(sizeof(MDType) + count * size);
return UntypedMDRVA::Allocate(minidump_size<MDType>::size() + count * size);
}
template<typename MDType>
inline bool TypedMDRVA<MDType>::CopyIndex(unsigned int index, MDType *item) {
assert(allocation_state_ == ARRAY);
return writer_->Copy(position_ + index * sizeof(MDType), item,
sizeof(MDType));
return writer_->Copy(position_ + index * minidump_size<MDType>::size(), item,
minidump_size<MDType>::size());
}
template<typename MDType>
@ -79,12 +80,13 @@ inline bool TypedMDRVA<MDType>::CopyIndexAfterObject(unsigned int index,
const void *src,
size_t size) {
assert(allocation_state_ == SINGLE_OBJECT_WITH_ARRAY);
return writer_->Copy(position_ + sizeof(MDType) + index * size, src, size);
return writer_->Copy(position_ + minidump_size<MDType>::size() + index * size,
src, size);
}
template<typename MDType>
inline bool TypedMDRVA<MDType>::Flush() {
return writer_->Copy(position_, &data_, sizeof(MDType));
return writer_->Copy(position_, &data_, minidump_size<MDType>::size());
}
} // namespace google_breakpad

View file

@ -200,12 +200,12 @@ class TypedMDRVA : public UntypedMDRVA {
// alter its contents.
MDType *get() { return &data_; }
// Allocates sizeof(MDType) bytes.
// Allocates minidump_size<MDType>::size() bytes.
// Must not call more than once.
// Return true on success, or false on failure
bool Allocate();
// Allocates sizeof(MDType) + |additional| bytes.
// Allocates minidump_size<MDType>::size() + |additional| bytes.
// Must not call more than once.
// Return true on success, or false on failure
bool Allocate(size_t additional);