mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
Remove trailing whitespace
This commit is contained in:
@@ -4,13 +4,13 @@
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@@ -40,45 +40,45 @@ namespace EQEmu {
|
||||
#endif
|
||||
};
|
||||
|
||||
MemoryMappedFile::MemoryMappedFile(std::string filename, uint32 size)
|
||||
MemoryMappedFile::MemoryMappedFile(std::string filename, uint32 size)
|
||||
: filename_(filename), size_(size) {
|
||||
imp_ = new Implementation;
|
||||
|
||||
|
||||
#ifdef _WINDOWS
|
||||
DWORD total_size = size + sizeof(shared_memory_struct);
|
||||
HANDLE file = CreateFile(filename.c_str(),
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
HANDLE file = CreateFile(filename.c_str(),
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
nullptr,
|
||||
OPEN_ALWAYS,
|
||||
0,
|
||||
nullptr);
|
||||
|
||||
|
||||
if(file == INVALID_HANDLE_VALUE) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
|
||||
}
|
||||
|
||||
|
||||
imp_->mapped_object_ = CreateFileMapping(file,
|
||||
nullptr,
|
||||
PAGE_READWRITE,
|
||||
PAGE_READWRITE,
|
||||
0,
|
||||
total_size,
|
||||
filename.c_str());
|
||||
|
||||
|
||||
if(!imp_->mapped_object_) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file.");
|
||||
}
|
||||
|
||||
|
||||
memory_ = reinterpret_cast<shared_memory_struct*>(MapViewOfFile(imp_->mapped_object_,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
total_size));
|
||||
|
||||
|
||||
if(!memory_) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file.");
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
size_t total_size = size + sizeof(shared_memory_struct);
|
||||
imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
@@ -98,11 +98,11 @@ namespace EQEmu {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
MemoryMappedFile::MemoryMappedFile(std::string filename)
|
||||
|
||||
MemoryMappedFile::MemoryMappedFile(std::string filename)
|
||||
: filename_(filename) {
|
||||
imp_ = new Implementation;
|
||||
|
||||
|
||||
//get existing size
|
||||
FILE *f = fopen(filename.c_str(), "rb");
|
||||
if(!f) {
|
||||
@@ -115,39 +115,39 @@ namespace EQEmu {
|
||||
|
||||
#ifdef _WINDOWS
|
||||
DWORD total_size = size + sizeof(shared_memory_struct);
|
||||
HANDLE file = CreateFile(filename.c_str(),
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
HANDLE file = CreateFile(filename.c_str(),
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
nullptr,
|
||||
OPEN_ALWAYS,
|
||||
0,
|
||||
nullptr);
|
||||
|
||||
|
||||
if(file == INVALID_HANDLE_VALUE) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not open a file for this shared memory segment.");
|
||||
}
|
||||
|
||||
|
||||
imp_->mapped_object_ = CreateFileMapping(file,
|
||||
nullptr,
|
||||
PAGE_READWRITE,
|
||||
PAGE_READWRITE,
|
||||
0,
|
||||
total_size,
|
||||
filename.c_str());
|
||||
|
||||
|
||||
if(!imp_->mapped_object_) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not create a file mapping for this shared memory file.");
|
||||
}
|
||||
|
||||
|
||||
memory_ = reinterpret_cast<shared_memory_struct*>(MapViewOfFile(imp_->mapped_object_,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
total_size));
|
||||
|
||||
|
||||
if(!memory_) {
|
||||
EQ_EXCEPT("Shared Memory", "Could not map a view of the shared memory file.");
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
size_t total_size = size + sizeof(shared_memory_struct);
|
||||
imp_->fd_ = open(filename.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
@@ -182,7 +182,7 @@ namespace EQEmu {
|
||||
#endif
|
||||
delete imp_;
|
||||
}
|
||||
|
||||
|
||||
void MemoryMappedFile::ZeroFile() {
|
||||
memset(reinterpret_cast<void*>(memory_), 0, sizeof(shared_memory_struct));
|
||||
memset(memory_->data, 0, size_);
|
||||
|
||||
Reference in New Issue
Block a user