mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
fix some memory management stupidity for Assignments
This commit is contained in:
parent
54b50e0e76
commit
67299b0eea
2 changed files with 25 additions and 0 deletions
|
@ -70,6 +70,30 @@ Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Assignment::Assignment(const Assignment& assignment) :
|
||||||
|
_pool(NULL),
|
||||||
|
_domainSocket(NULL)
|
||||||
|
{
|
||||||
|
_direction = assignment._direction;
|
||||||
|
_type = assignment._type;
|
||||||
|
|
||||||
|
if (assignment._pool) {
|
||||||
|
_pool = new char[strlen(assignment._pool)];
|
||||||
|
strcpy(_pool, assignment._pool);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assignment._domainSocket) {
|
||||||
|
if (assignment._domainSocket->sa_family == AF_INET) {
|
||||||
|
_domainSocket = (sockaddr*) new sockaddr_in;
|
||||||
|
memcpy(_domainSocket, assignment._domainSocket, sizeof(sockaddr_in));
|
||||||
|
} else {
|
||||||
|
_domainSocket = (sockaddr*) new sockaddr_in6;
|
||||||
|
memcpy(_domainSocket, assignment._domainSocket, sizeof(sockaddr_in6));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Assignment::~Assignment() {
|
Assignment::~Assignment() {
|
||||||
delete _domainSocket;
|
delete _domainSocket;
|
||||||
delete _pool;
|
delete _pool;
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
|
|
||||||
Assignment(Assignment::Direction direction, Assignment::Type type, const char* pool = NULL);
|
Assignment(Assignment::Direction direction, Assignment::Type type, const char* pool = NULL);
|
||||||
Assignment(const unsigned char* dataBuffer, int numBytes);
|
Assignment(const unsigned char* dataBuffer, int numBytes);
|
||||||
|
Assignment(const Assignment& assignment);
|
||||||
~Assignment();
|
~Assignment();
|
||||||
|
|
||||||
Assignment::Direction getDirection() const { return _direction; }
|
Assignment::Direction getDirection() const { return _direction; }
|
||||||
|
|
Loading…
Reference in a new issue