Changeset 1062 for trunk/libtorrent/src/net/data_buffer.h
- Timestamp:
- 07/05/08 08:13:12 (4 years ago)
- Files:
-
- 1 modified
-
trunk/libtorrent/src/net/data_buffer.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtorrent/src/net/data_buffer.h
r980 r1062 45 45 // Recipient must call clear() when done with the buffer. 46 46 struct DataBuffer { 47 DataBuffer() : m_data(NULL), m_end(NULL), m_copied(false) {} 48 DataBuffer(char* data, char* end) : m_data(data), m_end(end), m_copied(false) {} 47 DataBuffer() : m_data(NULL), m_end(NULL), m_owned(true) {} 48 DataBuffer(char* data, char* end) : m_data(data), m_end(end), m_owned(true) {} 49 50 DataBuffer clone() const { DataBuffer d = *this; d.m_owned = false; return d; } 49 51 50 52 char* data() const { return m_data; } 51 53 char* end() const { return m_end; } 52 54 53 bool copied() const { return m_copied; }55 bool owned() const { return m_owned; } 54 56 bool empty() const { return m_data == NULL; } 55 57 size_t length() const { return m_end - m_data; } 56 58 57 59 void clear(); 58 void set(char* data, char* end, bool copied);60 void set(char* data, char* end, bool owned); 59 61 60 62 private: … … 62 64 char* m_end; 63 65 64 // Used to indicate if buffer held by PCB is copiedand needs to be65 // deleted after transmission .66 bool m_ copied;66 // Used to indicate if buffer held by PCB is its own and needs to be 67 // deleted after transmission (false if shared with other connections). 68 bool m_owned; 67 69 }; 68 70 … … 73 75 74 76 m_data = m_end = NULL; 75 m_ copied = false;77 m_owned = false; 76 78 } 77 79 78 80 inline void 79 DataBuffer::set(char* data, char* end, bool copied) {81 DataBuffer::set(char* data, char* end, bool owned) { 80 82 m_data = data; 81 83 m_end = end; 82 m_ copied = copied;84 m_owned = owned; 83 85 } 84 86
