Skip to content

Commit

Permalink
IMAGES: Use ScopedPtr in the DDS decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Oct 29, 2016
1 parent 79e7fb8 commit 8b6f561
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/images/dds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* DDS (DirectDraw Surface) loading.
*/

#include "src/common/scopedptr.h"
#include "src/common/util.h"
#include "src/common/error.h"
#include "src/common/readstream.h"
Expand Down Expand Up @@ -196,22 +197,20 @@ void DDS::readBioWareHeader(Common::SeekableReadStream &dds, DataType &dataType)

// Detect how many mip maps are in the DDS
do {
MipMap *mipMap = new MipMap;
Common::ScopedPtr<MipMap> mipMap(new MipMap);

mipMap->width = MAX<uint32>(width, 1);
mipMap->height = MAX<uint32>(height, 1);

setSize(*mipMap);

if (fullDataSize < mipMap->size) {
// Wouldn't fit
delete mipMap;
// Wouldn't fit
if (fullDataSize < mipMap->size)
break;
}

fullDataSize -= mipMap->size;

_mipMaps.push_back(mipMap);
_mipMaps.push_back(mipMap.release());

width >>= 1;
height >>= 1;
Expand Down

0 comments on commit 8b6f561

Please sign in to comment.