From c9d1f9613e3ac18d5dd3b9432646e289bb88cec9 Mon Sep 17 00:00:00 2001 From: xmarvla Date: Wed, 15 Jun 2011 14:03:08 +0200 Subject: Add support for M730 Platform Added new command: System_StartCommRelay (For M730 platform). New state machine in Protrom Network Transmitter Handler. Small changes in Z protocol due to implementation of Communication Relay in Hassium Loaders. Add implementation for CriticalSection synchronization mechanism. ST-Ericsson ID: 325251 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10204 Depends-On: I0d34a2c4504a2b52ff5ab5efd2da36d8d1fa9816 Change-Id: I0d34a2c4504a2b52ff5ab5efd2da36d8d1fa9816 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/20944 Reviewed-by: QATOOLS Reviewed-by: Vlatko PISTOLOV Tested-by: Vlatko PISTOLOV --- source/utilities/MemMappedFile.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/utilities/MemMappedFile.cpp') diff --git a/source/utilities/MemMappedFile.cpp b/source/utilities/MemMappedFile.cpp index 8d5905d..835e401 100644 --- a/source/utilities/MemMappedFile.cpp +++ b/source/utilities/MemMappedFile.cpp @@ -136,16 +136,16 @@ uint8 *MemMappedFile::AllocateFileData(uint64 offset, uint64 size) return 0; } - uint32 alignedSize = (static_cast(size) + (alignmentLength_ - 1)) & (~(alignmentLength_ - 1)); + uint32 alignedSize = (static_cast(size) + (alignmentLength_ - 1)) & (~(alignmentLength_ - 1)); if (isMapped_) { if (size_ < offset + alignedSize) { uint8 *data = new uint8[alignedSize]; memcpy(data, mappedData_ + offset, static_cast(size)); return data; - } else { + } else { return mappedData_ + offset; - } + } } else { // file is not memory mapped fall back to plain read uint32 readSize = static_cast(size); @@ -192,7 +192,8 @@ uint8 *MemMappedFile::AllocateFileData(uint64 offset, uint64 size) void MemMappedFile::ReleaseFileData(uint8 *data, uint64 offset, uint64 size) { - uint32 alignedSize = (static_cast(size) + (alignmentLength_ - 1)) & (~(alignmentLength_ - 1)); + uint32 alignedSize = (static_cast(size) + (alignmentLength_ - 1)) & (~(alignmentLength_ - 1)); + if (!isMapped_ || size_ < offset + alignedSize) { delete[] data; } -- cgit v1.2.3