Commit 1e11657b authored by Fangjun KUANG's avatar Fangjun KUANG Committed by Alexander Alekhin

Merge pull request #8197 from csukuangfj/csukuangfj-patch-1

Fix typos in the documentation for AutoBuffer. (#8197)

* Allocate 1000 floats to match the documentation

Fix the documentation of `AutoBuffer`. By default, the following code
```.cpp
cv::AutoBuffer<float> m;
```` 
allocates only 264 floats. But the comment in the demonstration code says it allocates 1000 floats, which is 
not correct.

* fix typo in the comment.
parent 642e4d97
...@@ -102,7 +102,7 @@ CV_EXPORTS void setUseCollection(bool flag); // set implementation collection st ...@@ -102,7 +102,7 @@ CV_EXPORTS void setUseCollection(bool flag); // set implementation collection st
\code \code
void my_func(const cv::Mat& m) void my_func(const cv::Mat& m)
{ {
cv::AutoBuffer<float> buf; // create automatic buffer containing 1000 floats cv::AutoBuffer<float> buf(1000); // create automatic buffer containing 1000 floats
buf.allocate(m.rows); // if m.rows <= 1000, the pre-allocated buffer is used, buf.allocate(m.rows); // if m.rows <= 1000, the pre-allocated buffer is used,
// otherwise the buffer of "m.rows" floats will be allocated // otherwise the buffer of "m.rows" floats will be allocated
...@@ -137,9 +137,9 @@ public: ...@@ -137,9 +137,9 @@ public:
void resize(size_t _size); void resize(size_t _size);
//! returns the current buffer size //! returns the current buffer size
size_t size() const; size_t size() const;
//! returns pointer to the real buffer, stack-allocated or head-allocated //! returns pointer to the real buffer, stack-allocated or heap-allocated
operator _Tp* (); operator _Tp* ();
//! returns read-only pointer to the real buffer, stack-allocated or head-allocated //! returns read-only pointer to the real buffer, stack-allocated or heap-allocated
operator const _Tp* () const; operator const _Tp* () const;
protected: protected:
...@@ -147,7 +147,7 @@ protected: ...@@ -147,7 +147,7 @@ protected:
_Tp* ptr; _Tp* ptr;
//! size of the real buffer //! size of the real buffer
size_t sz; size_t sz;
//! pre-allocated buffer. At least 1 element to confirm C++ standard reqirements //! pre-allocated buffer. At least 1 element to confirm C++ standard requirements
_Tp buf[(fixed_size > 0) ? fixed_size : 1]; _Tp buf[(fixed_size > 0) ? fixed_size : 1];
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment