|
@@ -41,14 +41,16 @@ int bitmap_resize ( struct bitmap *bitmap, unsigned int new_length ) {
|
41
|
41
|
old_num_blocks = BITMAP_INDEX ( bitmap->length + BITMAP_BLKSIZE - 1 );
|
42
|
42
|
new_num_blocks = BITMAP_INDEX ( new_length + BITMAP_BLKSIZE - 1 );
|
43
|
43
|
|
44
|
|
- new_size = ( new_num_blocks * sizeof ( bitmap->blocks[0] ) );
|
45
|
|
- new_blocks = realloc ( bitmap->blocks, new_size );
|
46
|
|
- if ( ! new_blocks ) {
|
47
|
|
- DBGC ( bitmap, "Bitmap %p could not resize to %d bits\n",
|
48
|
|
- bitmap, new_length );
|
49
|
|
- return -ENOMEM;
|
|
44
|
+ if ( old_num_blocks != new_num_blocks ) {
|
|
45
|
+ new_size = ( new_num_blocks * sizeof ( bitmap->blocks[0] ) );
|
|
46
|
+ new_blocks = realloc ( bitmap->blocks, new_size );
|
|
47
|
+ if ( ! new_blocks ) {
|
|
48
|
+ DBGC ( bitmap, "Bitmap %p could not resize to %d "
|
|
49
|
+ "bits\n", bitmap, new_length );
|
|
50
|
+ return -ENOMEM;
|
|
51
|
+ }
|
|
52
|
+ bitmap->blocks = new_blocks;
|
50
|
53
|
}
|
51
|
|
- bitmap->blocks = new_blocks;
|
52
|
54
|
bitmap->length = new_length;
|
53
|
55
|
|
54
|
56
|
while ( old_num_blocks < new_num_blocks ) {
|