summaryrefslogtreecommitdiff
path: root/src/packet.cpp
diff options
context:
space:
mode:
authorAaron Marks <nymacro@gmail.com>2005-07-16 03:55:54 +0000
committerAaron Marks <nymacro@gmail.com>2005-07-16 03:55:54 +0000
commit34e887895276242efaf2e0b5f1700c1ab1d6b3db (patch)
tree8e2805ad893678364cde6ec1a37146c1bbecf075 /src/packet.cpp
parentca0ffbbacfcba5e0f019c83fd0b759752b192ca0 (diff)
downloadmanaserv-34e887895276242efaf2e0b5f1700c1ab1d6b3db.tar.gz
manaserv-34e887895276242efaf2e0b5f1700c1ab1d6b3db.tar.bz2
manaserv-34e887895276242efaf2e0b5f1700c1ab1d6b3db.tar.xz
manaserv-34e887895276242efaf2e0b5f1700c1ab1d6b3db.zip
Fixed problem with memory expanding in Packet.
Server now handles register requests.
Diffstat (limited to 'src/packet.cpp')
-rw-r--r--src/packet.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/packet.cpp b/src/packet.cpp
index 9ab27d84..6664235f 100644
--- a/src/packet.cpp
+++ b/src/packet.cpp
@@ -37,11 +37,15 @@ Packet::Packet(const char *data, int length):
Packet::~Packet()
{
// Clean up the data
- delete[] data;
+ if (data)
+ delete[] data;
}
void Packet::expand(unsigned int bytes)
{
- realloc(data, length + bytes);
+ char *newData = (char*)malloc(length + bytes);
+ memcpy(newData, (void*)data, length);
+ delete []data;
+ data = newData;
size += bytes;
}