Fix memory leak in modules tests
This commit is contained in:
3 files changed
+14
-21
No files matched your search
@@ -34,15 +34,12 @@ FilterComponentModule::FilterComponentModule()
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = ClpModuleFeature::None;
|
||||
m_pchModuleCategory = "Filtering";
|
||||
|
||||
m_pcFilteredFrame = NULL;
|
||||
}
|
||||
|
||||
bool FilterComponentModule::createFilter( unsigned int uiWidth, unsigned int uiHeight, unsigned int bitsPixel )
|
||||
{
|
||||
m_pcFilteredFrame = NULL;
|
||||
m_pcFilteredFrame = new CalypFrame( uiWidth, uiHeight, ClpPixelFormats::Gray, bitsPixel );
|
||||
return true;
|
||||
m_pcFilteredFrame = std::make_unique<CalypFrame>( uiWidth, uiHeight, ClpPixelFormats::Gray, bitsPixel );
|
||||
return m_pcFilteredFrame != nullptr;
|
||||
}
|
||||
|
||||
CalypFrame* FilterComponentModule::filterComponent( CalypFrame* InputFrame, int Component )
|
||||
@@ -51,14 +48,7 @@ CalypFrame* FilterComponentModule::filterComponent( CalypFrame* InputFrame, int
|
||||
ClpPel*** pppInputPelYUV = InputFrame->getPelBufferYUV();
|
||||
memcpy( pppOutputPelYUV[CLP_LUMA][0], pppInputPelYUV[Component][0],
|
||||
m_pcFilteredFrame->getWidth() * m_pcFilteredFrame->getHeight() * sizeof( ClpPel ) );
|
||||
return m_pcFilteredFrame;
|
||||
}
|
||||
|
||||
void FilterComponentModule::destroy()
|
||||
{
|
||||
if( m_pcFilteredFrame )
|
||||
delete m_pcFilteredFrame;
|
||||
m_pcFilteredFrame = NULL;
|
||||
return m_pcFilteredFrame.get();
|
||||
}
|
||||
|
||||
FilterComponentLuma::FilterComponentLuma()
|
||||
|
||||
@@ -31,22 +31,21 @@
|
||||
class FilterComponentModule : public CalypModuleIf
|
||||
{
|
||||
private:
|
||||
CalypFrame* m_pcFilteredFrame;
|
||||
std::unique_ptr<CalypFrame> m_pcFilteredFrame{ nullptr };
|
||||
|
||||
public:
|
||||
FilterComponentModule();
|
||||
virtual ~FilterComponentModule() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList ) = 0;
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList ) = 0;
|
||||
void destroy();
|
||||
|
||||
bool createFilter( unsigned int uiWidth, unsigned int uiHeight, unsigned int bitsPixel );
|
||||
CalypFrame* filterComponent( CalypFrame* InputFrame, int Component );
|
||||
};
|
||||
|
||||
class FilterComponentLuma : public FilterComponentModule
|
||||
class FilterComponentLuma : public FilterComponentModule,
|
||||
public CalypModuleInstace<FilterComponentLuma>
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( FilterComponentLuma )
|
||||
public:
|
||||
FilterComponentLuma();
|
||||
virtual ~FilterComponentLuma() {}
|
||||
@@ -54,9 +53,9 @@ public:
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
};
|
||||
|
||||
class FilterComponentChromaU : public FilterComponentModule
|
||||
class FilterComponentChromaU : public FilterComponentModule,
|
||||
public CalypModuleInstace<FilterComponentChromaU>
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( FilterComponentChromaU )
|
||||
public:
|
||||
FilterComponentChromaU();
|
||||
virtual ~FilterComponentChromaU() {}
|
||||
@@ -64,9 +63,9 @@ public:
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
};
|
||||
|
||||
class FilterComponentChromaV : public FilterComponentModule
|
||||
class FilterComponentChromaV : public FilterComponentModule,
|
||||
public CalypModuleInstace<FilterComponentChromaV>
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( FilterComponentChromaV )
|
||||
public:
|
||||
FilterComponentChromaV();
|
||||
virtual ~FilterComponentChromaV() {}
|
||||
|
||||
@@ -113,6 +113,7 @@ TEST_F( TestModuleCreate, CREATE_OK )
|
||||
moduleCreated = true;
|
||||
}
|
||||
EXPECT_EQ( moduleCreated, true );
|
||||
pcModule->destroy();
|
||||
}
|
||||
|
||||
TEST_F( TestModuleCreate, CREATE_FAIL_LESS_ONE )
|
||||
@@ -129,6 +130,7 @@ TEST_F( TestModuleCreate, CREATE_FAIL_LESS_ONE )
|
||||
}
|
||||
bool moduleCreated = pcModule->create( apcFrameList );
|
||||
EXPECT_NE( moduleCreated, true );
|
||||
pcModule->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +146,7 @@ TEST_F( TestModuleCreate, CREATE_FAIL_PLUS_ONE )
|
||||
}
|
||||
bool moduleCreated = pcModule->create( apcFrameList );
|
||||
EXPECT_NE( moduleCreated, true );
|
||||
pcModule->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,5 +162,6 @@ TEST_F( TestModuleCreate, CREATE_FAIL_NULL_FRAME )
|
||||
}
|
||||
bool moduleCreated = pcModule->create( apcFrameList );
|
||||
EXPECT_NE( moduleCreated, true );
|
||||
pcModule->destroy();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user