-rw-r--r-- | qmake/tools/qbitarray.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/qmake/tools/qbitarray.cpp b/qmake/tools/qbitarray.cpp index 4f4e14b..1aaf963 100644 --- a/qmake/tools/qbitarray.cpp +++ b/qmake/tools/qbitarray.cpp | |||
@@ -152,97 +152,98 @@ QBitArray::QBitArray() : QByteArray( 0, 0 ) | |||
152 | 152 | ||
153 | \sa fill() | 153 | \sa fill() |
154 | */ | 154 | */ |
155 | 155 | ||
156 | QBitArray::QBitArray( uint size ) : QByteArray( 0, 0 ) | 156 | QBitArray::QBitArray( uint size ) : QByteArray( 0, 0 ) |
157 | { | 157 | { |
158 | bitarr_data *x = new bitarr_data; | 158 | bitarr_data *x = new bitarr_data; |
159 | Q_CHECK_PTR( x ); | 159 | Q_CHECK_PTR( x ); |
160 | x->nbits = 0; | 160 | x->nbits = 0; |
161 | setSharedBlock( x ); | 161 | setSharedBlock( x ); |
162 | resize( size ); | 162 | resize( size ); |
163 | } | 163 | } |
164 | 164 | ||
165 | /*! | 165 | /*! |
166 | \fn QBitArray::QBitArray( const QBitArray &a ) | 166 | \fn QBitArray::QBitArray( const QBitArray &a ) |
167 | 167 | ||
168 | Constructs a shallow copy of \a a. | 168 | Constructs a shallow copy of \a a. |
169 | */ | 169 | */ |
170 | 170 | ||
171 | /*! | 171 | /*! |
172 | \fn QBitArray &QBitArray::operator=( const QBitArray &a ) | 172 | \fn QBitArray &QBitArray::operator=( const QBitArray &a ) |
173 | 173 | ||
174 | Assigns a shallow copy of \a a to this bit array and returns a | 174 | Assigns a shallow copy of \a a to this bit array and returns a |
175 | reference to this array. | 175 | reference to this array. |
176 | */ | 176 | */ |
177 | 177 | ||
178 | 178 | ||
179 | /*! | 179 | /*! |
180 | Pad last byte with 0-bits. | 180 | Pad last byte with 0-bits. |
181 | */ | 181 | */ |
182 | void QBitArray::pad0() | 182 | void QBitArray::pad0() |
183 | { | 183 | { |
184 | uint sz = size(); | 184 | uint sz = size(); |
185 | if ( sz && sz%8 ) | 185 | if ( sz && sz%8 ) |
186 | *(data()+sz/8) &= (1 << (sz%8)) - 1; | 186 | *(data()+sz/8) &= (1 << (sz%8)) - 1; |
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | /*! | 190 | /*! |
191 | \fn uint QBitArray::size() const | 191 | \fn uint QBitArray::size() const |
192 | 192 | ||
193 | Returns the bit array's size (number of bits). | 193 | Returns the bit array's size (number of bits). |
194 | 194 | ||
195 | \sa resize() | 195 | \sa resize() |
196 | */ | 196 | */ |
197 | 197 | ||
198 | /*! | 198 | /*! |
199 | Resizes the bit array to \a size bits and returns TRUE if the bit | 199 | Resizes the bit array to \a size bits and returns TRUE if the bit |
200 | array could be resized; otherwise returns FALSE. | 200 | array could be resized; otherwise returns FALSE. The array becomes |
201 | a null array if \a size == 0. | ||
201 | 202 | ||
202 | If the array is expanded, the new bits are set to 0. | 203 | If the array is expanded, the new bits are set to 0. |
203 | 204 | ||
204 | \sa size() | 205 | \sa size() |
205 | */ | 206 | */ |
206 | 207 | ||
207 | bool QBitArray::resize( uint size ) | 208 | bool QBitArray::resize( uint size ) |
208 | { | 209 | { |
209 | uint s = this->size(); | 210 | uint s = this->size(); |
210 | if ( !QByteArray::resize( (size+7)/8 ) ) | 211 | if ( !QByteArray::resize( (size+7)/8 ) ) |
211 | return FALSE; // cannot resize | 212 | return FALSE; // cannot resize |
212 | SHBLOCK->nbits = size; | 213 | SHBLOCK->nbits = size; |
213 | if ( size != 0 ) { // not null array | 214 | if ( size != 0 ) { // not null array |
214 | int ds = (int)(size+7)/8 - (int)(s+7)/8;// number of bytes difference | 215 | int ds = (int)(size+7)/8 - (int)(s+7)/8;// number of bytes difference |
215 | if ( ds > 0 ) // expanding array | 216 | if ( ds > 0 ) // expanding array |
216 | memset( data() + (s+7)/8, 0, ds );// reset new data | 217 | memset( data() + (s+7)/8, 0, ds );// reset new data |
217 | } | 218 | } |
218 | return TRUE; | 219 | return TRUE; |
219 | } | 220 | } |
220 | 221 | ||
221 | 222 | ||
222 | /*! | 223 | /*! |
223 | Fills the bit array with \a v (1's if \a v is TRUE, or 0's if \a v | 224 | Fills the bit array with \a v (1's if \a v is TRUE, or 0's if \a v |
224 | is FALSE). | 225 | is FALSE). |
225 | 226 | ||
226 | fill() resizes the bit array to \a size bits if \a size is | 227 | fill() resizes the bit array to \a size bits if \a size is |
227 | nonnegative. | 228 | nonnegative. |
228 | 229 | ||
229 | Returns FALSE if a nonnegative \e size was specified and the bit | 230 | Returns FALSE if a nonnegative \e size was specified and the bit |
230 | array could not be resized; otherwise returns TRUE. | 231 | array could not be resized; otherwise returns TRUE. |
231 | 232 | ||
232 | \sa resize() | 233 | \sa resize() |
233 | */ | 234 | */ |
234 | 235 | ||
235 | bool QBitArray::fill( bool v, int size ) | 236 | bool QBitArray::fill( bool v, int size ) |
236 | { | 237 | { |
237 | if ( size >= 0 ) { // resize first | 238 | if ( size >= 0 ) { // resize first |
238 | if ( !resize( size ) ) | 239 | if ( !resize( size ) ) |
239 | return FALSE; // cannot resize | 240 | return FALSE; // cannot resize |
240 | } else { | 241 | } else { |
241 | size = this->size(); | 242 | size = this->size(); |
242 | } | 243 | } |
243 | if ( size > 0 ) | 244 | if ( size > 0 ) |
244 | memset( data(), v ? 0xff : 0, (size + 7) / 8 ); | 245 | memset( data(), v ? 0xff : 0, (size + 7) / 8 ); |
245 | if ( v ) | 246 | if ( v ) |
246 | pad0(); | 247 | pad0(); |
247 | return TRUE; | 248 | return TRUE; |
248 | } | 249 | } |