Showing
1 changed file
with
4 additions
and
9 deletions
... | ... | @@ -204,16 +204,11 @@ TR_malloc(size_t size) |
204 | 204 | size = 1 << (MIN_BITS - 1); |
205 | 205 | idx = 0; |
206 | 206 | } else { |
207 | - size_t mask; | |
208 | - | |
209 | - idx = TR_bitwidth(size); | |
210 | - mask = (1 << (idx + 1)) - 1; | |
207 | + // size-1 to ensure that powers of two will not be | |
208 | + // changed to the next power of two | |
209 | + idx = TR_bitwidth(size-1) + 1; | |
210 | + size = 1 << idx; | |
211 | 211 | idx -= (MIN_BITS - 1); |
212 | - | |
213 | - if (size != (size & ~(mask >> 1))) { | |
214 | - size = (size << 1) & ~mask; | |
215 | - idx++; | |
216 | - } | |
217 | 212 | } |
218 | 213 | } |
219 | 214 | ... | ... |
Please
register
or
login
to post a comment