diff options
author | Maciej Cencora <m.cencora@gmail.com> | 2009-11-23 21:59:08 +0100 |
---|---|---|
committer | Maciej Cencora <m.cencora@gmail.com> | 2009-11-23 21:59:08 +0100 |
commit | 960464e42dce138fde11c379ce7744bc4be14aa2 (patch) | |
tree | f7bc2d48408d7f98d06f744cab779c1b00564bd4 /src | |
parent | 635823d267c709f37c7a01844e03ebd7074bf4e2 (diff) |
radeon: fix errors in miptree related function
- typo
- memory leak
- off by one (spotted by airlied)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c index a11b5b9979..46603de2e7 100644 --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c @@ -492,11 +492,12 @@ static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj, unsigned firstLevel, unsigned lastLevel) { - const unsigned numLevels = lastLevel - firstLevel; + const unsigned numLevels = lastLevel - firstLevel + 1; unsigned *mtSizes = calloc(numLevels, sizeof(unsigned)); radeon_mipmap_tree **mts = calloc(numLevels, sizeof(radeon_mipmap_tree *)); unsigned mtCount = 0; unsigned maxMtIndex = 0; + radeon_mipmap_tree *tmp; for (unsigned level = firstLevel; level <= lastLevel; ++level) { radeon_texture_image *img = get_radeon_texture_image(texObj->base.Image[0][level]); @@ -518,7 +519,7 @@ static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj, if (!found) { mtSizes[mtCount] += img->mt->levels[img->mtlevel].size; - mts[mtCount++] = img->mt; + mts[mtCount] = img->mt; mtCount++; } } @@ -533,7 +534,11 @@ static radeon_mipmap_tree * get_biggest_matching_miptree(radeonTexObj *texObj, } } - return mts[maxMtIndex]; + tmp = mts[maxMtIndex]; + free(mtSizes); + free(mts); + + return tmp; } /** |