Mercurial > hg > svcore
comparison base/RingBuffer.h @ 575:8688430850d6
* either I'm going mad or the compiler is... valgrind and sizeof both
seem to think that reading or writing m_size is reading beyond the end
of the object, unless I add m_spare padding... why?
author | Chris Cannam |
---|---|
date | Mon, 16 Mar 2009 16:32:02 +0000 |
parents | 2d551c765d51 |
children | 2ba202c5be8d |
comparison
equal
deleted
inserted
replaced
574:2d551c765d51 | 575:8688430850d6 |
---|---|
163 T *m_buffer; | 163 T *m_buffer; |
164 bool m_mlocked; | 164 bool m_mlocked; |
165 size_t m_writer; | 165 size_t m_writer; |
166 size_t *m_readers; | 166 size_t *m_readers; |
167 size_t m_size; | 167 size_t m_size; |
168 size_t m_spare; | |
168 | 169 |
169 static Scavenger<ScavengerArrayWrapper<T> > m_scavenger; | 170 static Scavenger<ScavengerArrayWrapper<T> > m_scavenger; |
170 | 171 |
171 private: | 172 private: |
172 RingBuffer(const RingBuffer &); // not provided | 173 RingBuffer(const RingBuffer &); // not provided |
185 m_size(n + 1) | 186 m_size(n + 1) |
186 { | 187 { |
187 #ifdef DEBUG_RINGBUFFER | 188 #ifdef DEBUG_RINGBUFFER |
188 std::cerr << "RingBuffer<T," << N << ">[" << this << "]::RingBuffer(" << n << ")" << std::endl; | 189 std::cerr << "RingBuffer<T," << N << ">[" << this << "]::RingBuffer(" << n << ")" << std::endl; |
189 #endif | 190 #endif |
190 | 191 /* |
191 std::cerr << "note: sizeof(RingBuffer<T,N> = " << sizeof(RingBuffer<T,N>) << std::endl; | 192 std::cerr << "note: sizeof(RingBuffer<T,N> = " << sizeof(RingBuffer<T,N>) << ")" << std::endl; |
192 | 193 |
194 std::cerr << "this = " << this << std::endl; | |
195 std::cerr << "&m_buffer = " << &m_buffer << std::endl; | |
196 std::cerr << "&m_mlocked = " << &m_mlocked << std::endl; | |
197 std::cerr << "&m_writer = " << &m_writer << std::endl; | |
198 std::cerr << "&m_readers = " << &m_readers << std::endl; | |
199 std::cerr << "&m_size = " << &m_size << std::endl; | |
200 */ | |
193 for (int i = 0; i < N; ++i) m_readers[i] = 0; | 201 for (int i = 0; i < N; ++i) m_readers[i] = 0; |
194 | 202 |
195 m_scavenger.scavenge(); | 203 m_scavenger.scavenge(); |
196 } | 204 } |
197 | 205 |