Browse Source

memory fixes with free/delete/new/malloc

pull/7/head
Stéphane Charette 9 months ago
parent
commit
27579ca966
  1. 3
      .gitignore
  2. 4
      lib/App/common/kernelModuleEmbedVideo.cpp
  3. 20
      lib/components/base/basicRing.h

3
.gitignore

@ -1,3 +1,4 @@
*.kdev4
*.[oa]
*.vpwhist
*.vtg
@ -125,4 +126,4 @@ Projects/img_mill/Debug_CPU_ONLY/*
Projects/img_mill/side/DarkHelp
Projects/img_mill/side/codeberg_darknet
Projects/img_mill/side/DarkHelp/*
Projects/img_mill/side/codeberg_darknet/*
Projects/img_mill/side/codeberg_darknet/*

4
lib/App/common/kernelModuleEmbedVideo.cpp

@ -1523,7 +1523,7 @@ bool kernelModuleEmbedVideo::dispatchEvent( EVENT_CONTAINER *Evt ){
if( tData ){
if( !saveStreamPicture( tData ) ) LOG_ERROR("Save Error!");
tData->assoc_event_ids.clear();
delete( tData );
free( tData );
Evt->m_pEvtData = NULL;
#ifdef DEBUG_EXTRA
LOG("Event Data Saved!");
@ -3883,7 +3883,7 @@ void streamHandler::m_fThreadProc( void ){
//m_qEncodingQueue.pop();
//m_mEncodingQueueProtector.unlock();
sws_scale( m_pConvertCtx, tData->data, tData->linesize, 0, tData->rows, m_pAVFrame->data, m_pAVFrame->linesize );
free( tData->data[0] );
free( tData->data[0] );
/*

20
lib/components/base/basicRing.h

@ -7,7 +7,7 @@
/**
* TODO: Add class description
*
*
* @author Gagua
*/
template <class T> class basicRing {
@ -61,8 +61,7 @@ template <class T> int basicRing<T>::push( T *ptr ){
int RetVal;
m_pAccessMutex.lock();
if ( last == NULL ){
//last = new basicRingElement<T>();
last = ( basicRingElement<T> *) malloc ( sizeof( basicRingElement<T> ) );
last = new basicRingElement<T>();
if( last != NULL ) {
first = last;
last->prev = NULL;
@ -72,11 +71,10 @@ template <class T> int basicRing<T>::push( T *ptr ){
return -1;
};
} else {
//last->next = new basicRingElement<T>();
last->next = ( basicRingElement<T> *) malloc ( sizeof( basicRingElement<T> ) );
last->next = new basicRingElement<T>();
if( last->next!= NULL ) {
last->next->prev = last;
last = last->next;
last = last->next;
} else {
m_pAccessMutex.unlock();
return -1;
@ -94,7 +92,7 @@ template <class T> int basicRing<T>::add(T* ptr) {
int RetVal;
m_pAccessMutex.lock();
if (first == NULL) {
first = (basicRingElement<T>*) malloc(sizeof(basicRingElement<T>));
first = new basicRingElement<T>();
if (first != NULL) {
last = first;
first->prev = NULL;
@ -105,7 +103,7 @@ template <class T> int basicRing<T>::add(T* ptr) {
};
} else {
basicRingElement<T>* tVal;
tVal = (basicRingElement<T>*) malloc(sizeof(basicRingElement<T>));
tVal = new basicRingElement<T>();
if (tVal != NULL) {
tVal->next = first;
first->prev = tVal;
@ -195,11 +193,11 @@ template <class T> int basicRing<T>::removeAt( basicRingElement<T> *&cursor ){
template <class T> T *basicRing<T>::pop( void ){
basicRingElement<T> *temp;
T *RetVal;
m_pAccessMutex.lock();
m_pAccessMutex.lock();
if( first != NULL ){
if (first == last) last = NULL;
RetVal = first->data;
temp = first->next;
temp = first->next;
delete first;
first = temp;
count --;
@ -284,7 +282,7 @@ template <class T> void basicRing<T>::getSequentalDown( void ){
template <class T> basicRing<T>::~basicRing(){
basicRingElement<T> *cursor;
cursor = begin();
m_pAccessMutex.unlock();
m_pAccessMutex.unlock();
while( removeAt( cursor ) );
};

Loading…
Cancel
Save