diff options
author | Aaron Marks <nymacro@gmail.com> | 2005-07-16 03:55:54 +0000 |
---|---|---|
committer | Aaron Marks <nymacro@gmail.com> | 2005-07-16 03:55:54 +0000 |
commit | 34e887895276242efaf2e0b5f1700c1ab1d6b3db (patch) | |
tree | 8e2805ad893678364cde6ec1a37146c1bbecf075 /src/packet.cpp | |
parent | ca0ffbbacfcba5e0f019c83fd0b759752b192ca0 (diff) | |
download | manaserv-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.cpp | 8 |
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; } |