Planeshift
|
00001 // Copyright (c) 2006, Google Inc. 00002 // All rights reserved. 00003 // 00004 // Redistribution and use in source and binary forms, with or without 00005 // modification, are permitted provided that the following conditions are 00006 // met: 00007 // 00008 // * Redistributions of source code must retain the above copyright 00009 // notice, this list of conditions and the following disclaimer. 00010 // * Redistributions in binary form must reproduce the above 00011 // copyright notice, this list of conditions and the following disclaimer 00012 // in the documentation and/or other materials provided with the 00013 // distribution. 00014 // * Neither the name of Google Inc. nor the names of its 00015 // contributors may be used to endorse or promote products derived from 00016 // this software without specific prior written permission. 00017 // 00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00022 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00024 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00025 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00026 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00027 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00028 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 00030 // minidump_file_writer-inl.h: Minidump file writer implementation. 00031 // 00032 // See minidump_file_writer.h for documentation. 00033 00034 #ifndef CLIENT_MINIDUMP_FILE_WRITER_INL_H__ 00035 #define CLIENT_MINIDUMP_FILE_WRITER_INL_H__ 00036 00037 #include <assert.h> 00038 00039 #include "client/minidump_file_writer.h" 00040 #include "google_breakpad/common/minidump_size.h" 00041 00042 namespace google_breakpad { 00043 00044 template<typename MDType> 00045 inline bool TypedMDRVA<MDType>::Allocate() { 00046 allocation_state_ = SINGLE_OBJECT; 00047 return UntypedMDRVA::Allocate(minidump_size<MDType>::size()); 00048 } 00049 00050 template<typename MDType> 00051 inline bool TypedMDRVA<MDType>::Allocate(size_t additional) { 00052 allocation_state_ = SINGLE_OBJECT; 00053 return UntypedMDRVA::Allocate(minidump_size<MDType>::size() + additional); 00054 } 00055 00056 template<typename MDType> 00057 inline bool TypedMDRVA<MDType>::AllocateArray(size_t count) { 00058 assert(count); 00059 allocation_state_ = ARRAY; 00060 return UntypedMDRVA::Allocate(minidump_size<MDType>::size() * count); 00061 } 00062 00063 template<typename MDType> 00064 inline bool TypedMDRVA<MDType>::AllocateObjectAndArray(size_t count, 00065 size_t length) { 00066 assert(count && length); 00067 allocation_state_ = SINGLE_OBJECT_WITH_ARRAY; 00068 return UntypedMDRVA::Allocate(minidump_size<MDType>::size() + count * length); 00069 } 00070 00071 template<typename MDType> 00072 inline bool TypedMDRVA<MDType>::CopyIndex(unsigned int index, MDType *item) { 00073 assert(allocation_state_ == ARRAY); 00074 return writer_->Copy( 00075 static_cast<MDRVA>(position_ + index * minidump_size<MDType>::size()), 00076 item, minidump_size<MDType>::size()); 00077 } 00078 00079 template<typename MDType> 00080 inline bool TypedMDRVA<MDType>::CopyIndexAfterObject(unsigned int index, 00081 const void *src, 00082 size_t length) { 00083 assert(allocation_state_ == SINGLE_OBJECT_WITH_ARRAY); 00084 return writer_->Copy( 00085 static_cast<MDRVA>(position_ + minidump_size<MDType>::size() 00086 + index * length), 00087 src, length); 00088 } 00089 00090 template<typename MDType> 00091 inline bool TypedMDRVA<MDType>::Flush() { 00092 return writer_->Copy(position_, &data_, minidump_size<MDType>::size()); 00093 } 00094 00095 } // namespace google_breakpad 00096 00097 #endif // CLIENT_MINIDUMP_FILE_WRITER_INL_H__