diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-06-05 18:48:13 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-06-05 18:48:13 +0000 |
commit | 6fd963c988199937d48a583b42c3d1217ab31f60 (patch) | |
tree | 7f72bb93e311108edccf1f6ffebce70bdc917679 /src | |
parent | 8c2c728ce5aa1c1941426d0f8e9ab27762ef6754 (diff) | |
download | libbu++-6fd963c988199937d48a583b42c3d1217ab31f60.tar.gz libbu++-6fd963c988199937d48a583b42c3d1217ab31f60.tar.bz2 libbu++-6fd963c988199937d48a583b42c3d1217ab31f60.tar.xz libbu++-6fd963c988199937d48a583b42c3d1217ab31f60.zip |
Nevermind, it's good to use with objects or anything, they are now destroyed
and constructed properly :-P
Diffstat (limited to 'src')
-rw-r--r-- | src/ringbuffer.h | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/ringbuffer.h b/src/ringbuffer.h index 9480043..625f65b 100644 --- a/src/ringbuffer.h +++ b/src/ringbuffer.h | |||
@@ -16,15 +16,11 @@ namespace Bu | |||
16 | nEnd( -2 ) | 16 | nEnd( -2 ) |
17 | { | 17 | { |
18 | aData = va.allocate( nCapacity ); | 18 | aData = va.allocate( nCapacity ); |
19 | for( int j = 0; j < nCapacity; j++ ) | ||
20 | { | ||
21 | va.construct( &aData[j], value() ); | ||
22 | } | ||
23 | } | 19 | } |
24 | 20 | ||
25 | virtual ~RingBuffer() | 21 | virtual ~RingBuffer() |
26 | { | 22 | { |
27 | for( int j = 0; j < nCapacity; j++ ) | 23 | for( int j = nStart; j < nEnd; j=(j+1%nCapacity) ) |
28 | { | 24 | { |
29 | va.destroy( &aData[j] ); | 25 | va.destroy( &aData[j] ); |
30 | } | 26 | } |
@@ -52,7 +48,7 @@ namespace Bu | |||
52 | { | 48 | { |
53 | nStart = 0; | 49 | nStart = 0; |
54 | nEnd = 1; | 50 | nEnd = 1; |
55 | aData[0] = v; | 51 | va.construct( &aData[0], v ); |
56 | } | 52 | } |
57 | else if( nStart == nEnd ) | 53 | else if( nStart == nEnd ) |
58 | { | 54 | { |
@@ -60,7 +56,7 @@ namespace Bu | |||
60 | } | 56 | } |
61 | else | 57 | else |
62 | { | 58 | { |
63 | aData[nEnd] = v; | 59 | va.construct( &aData[nEnd], v ); |
64 | nEnd = (nEnd+1)%nCapacity; | 60 | nEnd = (nEnd+1)%nCapacity; |
65 | } | 61 | } |
66 | } | 62 | } |
@@ -74,6 +70,7 @@ namespace Bu | |||
74 | else | 70 | else |
75 | { | 71 | { |
76 | value &v = aData[nStart]; | 72 | value &v = aData[nStart]; |
73 | va.destroy( &aData[nStart] ); | ||
77 | nStart = (nStart+1)%nCapacity; | 74 | nStart = (nStart+1)%nCapacity; |
78 | if( nStart == nEnd ) | 75 | if( nStart == nEnd ) |
79 | { | 76 | { |