Actions
Cleanup #4101
closedbuffer::list::iterator constructor should be private
Status:
Rejected
Priority:
Low
Assignee:
-
Category:
common
Target version:
-
% Done:
0%
Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:
Description
The
iterator(list *l, unsigned o, std::list<ptr>::iterator ip, unsigned po)
(github) constructor is used by the bufferlist end() method . It can only be properly initialized if given non const access to the _buffers data member.
It can only be initialized with inconsistent arguments when called outside of the bufferlist class.
To make it clear that this constructor is for internal use only, it could be made private. The bufferlist class could be made a friend of the bufferlist::iterator class.
diff --git a/src/include/buffer.h b/src/include/buffer.h index 4f87ed7..55a5e5b 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -231,6 +231,10 @@ public: unsigned off; // in bl std::list<ptr>::iterator p; unsigned p_off; // in *p + + iterator(list *l, unsigned o, std::list<ptr>::iterator ip, unsigned po) : + bl(l), ls(&bl->_buffers), off(o), p(ip), p_off(po) { } + public: // constructor. position. iterator() : @@ -239,8 +243,6 @@ public: bl(l), ls(&bl->_buffers), off(0), p(ls->begin()), p_off(0) { advance(o); } - iterator(list *l, unsigned o, std::list<ptr>::iterator ip, unsigned po) : - bl(l), ls(&bl->_buffers), off(o), p(ip), p_off(po) { } iterator(const iterator& other) : bl(other.bl), ls(other.ls), @@ -289,6 +291,7 @@ public: void copy_in(unsigned len, const char *src); void copy_in(unsigned len, const list& otherl); + friend class list; }; private:
Updated by Loïc Dachary about 7 years ago
- Status changed from New to Rejected
the code has changed in the past two years and the part targeted by this cleanup is no longer there
Actions