Fix memory leaks.
This commit is contained in:
@ -29,10 +29,11 @@ class AutoPtr
|
|||||||
NV_FORBID_HEAPALLOC();
|
NV_FORBID_HEAPALLOC();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Ctor. */
|
/// Default ctor.
|
||||||
explicit AutoPtr( T * p ) {
|
AutoPtr() : m_ptr(NULL) { }
|
||||||
m_ptr = p;
|
|
||||||
}
|
/// Ctor.
|
||||||
|
explicit AutoPtr( T * p ) : m_ptr(p) { }
|
||||||
|
|
||||||
/** Dtor. Deletes owned pointer. */
|
/** Dtor. Deletes owned pointer. */
|
||||||
~AutoPtr() {
|
~AutoPtr() {
|
||||||
@ -69,13 +70,23 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Const pointer equal comparation. */
|
/** Const pointer equal comparation. */
|
||||||
bool operator == (const T * const p) const {
|
friend bool operator == (const AutoPtr<T> & ap, const T * const p) {
|
||||||
return (m_ptr == p);
|
return (ap.ptr() == p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Const pointer nequal comparation. */
|
/** Const pointer nequal comparation. */
|
||||||
bool operator != (const T * const p) const {
|
friend bool operator != (const AutoPtr<T> & ap, const T * const p) {
|
||||||
return (m_ptr != p);
|
return (ap.ptr() != p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Const pointer equal comparation. */
|
||||||
|
friend bool operator == (const T * const p, const AutoPtr<T> & ap) {
|
||||||
|
return (ap.ptr() == p);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Const pointer nequal comparation. */
|
||||||
|
friend bool operator != (const T * const p, const AutoPtr<T> & ap) {
|
||||||
|
return (ap.ptr() != p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -843,12 +843,11 @@ bool nv::ImageIO::saveFloatTIFF(const char * fileName, FloatImage *fimage)
|
|||||||
TIFFSetField(image, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
|
TIFFSetField(image, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
|
||||||
TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 32);
|
TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 32);
|
||||||
|
|
||||||
uint32 rowsperstrip = TIFFDefaultStripSize(image, -1);
|
uint32 rowsperstrip = TIFFDefaultStripSize(image, (uint32)-1);
|
||||||
|
|
||||||
TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
|
TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
|
||||||
TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS);
|
TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS);
|
||||||
TIFFSetField(image, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
TIFFSetField(image, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
|
||||||
TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, -1L);
|
|
||||||
|
|
||||||
TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#ifndef NV_TT_INPUTOPTIONS_H
|
#ifndef NV_TT_INPUTOPTIONS_H
|
||||||
#define NV_TT_INPUTOPTIONS_H
|
#define NV_TT_INPUTOPTIONS_H
|
||||||
|
|
||||||
|
#include <nvcore/Ptr.h>
|
||||||
#include <nvmath/Vector.h>
|
#include <nvmath/Vector.h>
|
||||||
#include <nvimage/Image.h>
|
#include <nvimage/Image.h>
|
||||||
#include "nvtt.h"
|
#include "nvtt.h"
|
||||||
@ -75,7 +76,6 @@ namespace nvtt
|
|||||||
struct InputOptions::Private::Image
|
struct InputOptions::Private::Image
|
||||||
{
|
{
|
||||||
Image() {}
|
Image() {}
|
||||||
~Image() { delete data; }
|
|
||||||
|
|
||||||
int mipLevel;
|
int mipLevel;
|
||||||
int face;
|
int face;
|
||||||
@ -84,7 +84,7 @@ namespace nvtt
|
|||||||
int height;
|
int height;
|
||||||
int depth;
|
int depth;
|
||||||
|
|
||||||
nv::Image * data;
|
nv::AutoPtr<nv::Image> data;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // nvtt namespace
|
} // nvtt namespace
|
||||||
|
@ -409,11 +409,11 @@ bool nvtt::compress(const InputOptions & inputOptions, const OutputOptions & out
|
|||||||
// Convert to normal map.
|
// Convert to normal map.
|
||||||
if (inputOptions.m.convertToNormalMap)
|
if (inputOptions.m.convertToNormalMap)
|
||||||
{
|
{
|
||||||
floatImage = createNormalMap(mipmap.data, (FloatImage::WrapMode)inputOptions.m.wrapMode, inputOptions.m.heightFactors, inputOptions.m.bumpFrequencyScale);
|
floatImage = createNormalMap(mipmap.data.ptr(), (FloatImage::WrapMode)inputOptions.m.wrapMode, inputOptions.m.heightFactors, inputOptions.m.bumpFrequencyScale);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lastImage = img = mipmap.data;
|
lastImage = img = mipmap.data.ptr();
|
||||||
|
|
||||||
// Delete float image.
|
// Delete float image.
|
||||||
floatImage = NULL;
|
floatImage = NULL;
|
||||||
|
Reference in New Issue
Block a user