Imported memory_buffer files from inv2 branch

This commit is contained in:
Uleat
2016-05-27 20:39:11 -04:00
parent 0ecc702612
commit a37a811014
6 changed files with 415 additions and 79 deletions
-43
View File
@@ -415,46 +415,3 @@ void find_replace(std::string& string_subject, const std::string& search_string,
index = string_subject.find_first_of(search_string);
}
}
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
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
*/
void EQEmu::OutBuffer::overwrite(OutBuffer::pos_type position, const char *_Str, std::streamsize _Count)
{
auto last_pos = tellp();
seekp(position);
write(_Str, _Count);
seekp(last_pos);
}
uchar* EQEmu::OutBuffer::detach()
{
size_t buffer_size = tellp();
if (buffer_size == 0)
return nullptr;
auto out_buffer = new uchar[buffer_size];
memcpy(out_buffer, str().c_str(), buffer_size);
flush();
return out_buffer;
}