Debian Codegraph @

protolib/src/sim/ns/tcp/TCPData.cpp

raw
1 /*
2 * TcpData.cpp
3 *
4 * Created by Ian Taylor on 28/12/2006.
5 *
6 */
7
8 #include "TCPData.h"
9
10 void TcpData::setData(const char* b, int size) {
11 if (b == NULL) {
12 bytes_ = NULL;
13 size_ = 0;
14 } else {
15 PLOG(PL_DEBUG, "TcpData: Setting creating data %i bytes\n", size);
16 size_ = size;
17 bytes_ = new char[size_];
18 // assert(bytes_ != NULL);
19 memcpy(bytes_, b, size_);
20 }
21 }
22
23 TcpData::~TcpData() {
24 PLOG(PL_DEBUG, "TcpData Deleting Data Object\n");
25 // if (bytes_ != NULL) // don't delete data, that is up to application to free
26 // delete []bytes_;
27 }
28
29
30 AppData* TcpData::copy() {
31 TcpData *tcpData = new TcpData();
32 tcpData->setData(getData(), getDataSize());
33 return tcpData;
34 }
35
36