Skip to content

Commit

Permalink
include/buffer.h: fix operator=
Browse files Browse the repository at this point in the history
Fix operator=: return "iterator&" instead of 'iterator'. Check if 'this'
equals 'other' before set anything.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
  • Loading branch information
dalgaaf authored and Sage Weil committed Feb 6, 2013
1 parent ad526c0 commit 0327cba
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/include/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class buffer {
p(other.p),
p_off(other.p_off) {}

iterator operator=(const iterator& other) {
iterator& operator=(const iterator& other) {
if (this != &other) {
bl = other.bl;
ls = other.ls;
Expand Down Expand Up @@ -305,8 +305,10 @@ class buffer {

list(const list& other) : _buffers(other._buffers), _len(other._len), last_p(this) { }
list& operator= (const list& other) {
_buffers = other._buffers;
_len = other._len;
if (this != &other) {
_buffers = other._buffers;
_len = other._len;
}
return *this;
}

Expand Down

0 comments on commit 0327cba

Please sign in to comment.