Browse Source

memory fixes with free/delete/new/malloc

pull/7/head
Stéphane Charette 10 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] *.[oa]
*.vpwhist *.vpwhist
*.vtg *.vtg
@ -125,4 +126,4 @@ Projects/img_mill/Debug_CPU_ONLY/*
Projects/img_mill/side/DarkHelp Projects/img_mill/side/DarkHelp
Projects/img_mill/side/codeberg_darknet Projects/img_mill/side/codeberg_darknet
Projects/img_mill/side/DarkHelp/* 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( tData ){
if( !saveStreamPicture( tData ) ) LOG_ERROR("Save Error!"); if( !saveStreamPicture( tData ) ) LOG_ERROR("Save Error!");
tData->assoc_event_ids.clear(); tData->assoc_event_ids.clear();
delete( tData );
free( tData );
Evt->m_pEvtData = NULL; Evt->m_pEvtData = NULL;
#ifdef DEBUG_EXTRA #ifdef DEBUG_EXTRA
LOG("Event Data Saved!"); LOG("Event Data Saved!");
@ -3883,7 +3883,7 @@ void streamHandler::m_fThreadProc( void ){
//m_qEncodingQueue.pop(); //m_qEncodingQueue.pop();
//m_mEncodingQueueProtector.unlock(); //m_mEncodingQueueProtector.unlock();
sws_scale( m_pConvertCtx, tData->data, tData->linesize, 0, tData->rows, m_pAVFrame->data, m_pAVFrame->linesize ); 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 * TODO: Add class description
*
*
* @author Gagua * @author Gagua
*/ */
template <class T> class basicRing { template <class T> class basicRing {
@ -61,8 +61,7 @@ template <class T> int basicRing<T>::push( T *ptr ){
int RetVal; int RetVal;
m_pAccessMutex.lock(); m_pAccessMutex.lock();
if ( last == NULL ){ if ( last == NULL ){
//last = new basicRingElement<T>();
last = ( basicRingElement<T> *) malloc ( sizeof( basicRingElement<T> ) );
last = new basicRingElement<T>();
if( last != NULL ) { if( last != NULL ) {
first = last; first = last;
last->prev = NULL; last->prev = NULL;
@ -72,11 +71,10 @@ template <class T> int basicRing<T>::push( T *ptr ){
return -1; return -1;
}; };
} else { } else {
//last->next = new basicRingElement<T>();
last->next = ( basicRingElement<T> *) malloc ( sizeof( basicRingElement<T> ) );
last->next = new basicRingElement<T>();
if( last->next!= NULL ) { if( last->next!= NULL ) {
last->next->prev = last; last->next->prev = last;
last = last->next;
last = last->next;
} else { } else {
m_pAccessMutex.unlock(); m_pAccessMutex.unlock();
return -1; return -1;
@ -94,7 +92,7 @@ template <class T> int basicRing<T>::add(T* ptr) {
int RetVal; int RetVal;
m_pAccessMutex.lock(); m_pAccessMutex.lock();
if (first == NULL) { if (first == NULL) {
first = (basicRingElement<T>*) malloc(sizeof(basicRingElement<T>));
first = new basicRingElement<T>();
if (first != NULL) { if (first != NULL) {
last = first; last = first;
first->prev = NULL; first->prev = NULL;
@ -105,7 +103,7 @@ template <class T> int basicRing<T>::add(T* ptr) {
}; };
} else { } else {
basicRingElement<T>* tVal; basicRingElement<T>* tVal;
tVal = (basicRingElement<T>*) malloc(sizeof(basicRingElement<T>));
tVal = new basicRingElement<T>();
if (tVal != NULL) { if (tVal != NULL) {
tVal->next = first; tVal->next = first;
first->prev = tVal; 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 ){ template <class T> T *basicRing<T>::pop( void ){
basicRingElement<T> *temp; basicRingElement<T> *temp;
T *RetVal; T *RetVal;
m_pAccessMutex.lock();
m_pAccessMutex.lock();
if( first != NULL ){ if( first != NULL ){
if (first == last) last = NULL; if (first == last) last = NULL;
RetVal = first->data; RetVal = first->data;
temp = first->next;
temp = first->next;
delete first; delete first;
first = temp; first = temp;
count --; count --;
@ -284,7 +282,7 @@ template <class T> void basicRing<T>::getSequentalDown( void ){
template <class T> basicRing<T>::~basicRing(){ template <class T> basicRing<T>::~basicRing(){
basicRingElement<T> *cursor; basicRingElement<T> *cursor;
cursor = begin(); cursor = begin();
m_pAccessMutex.unlock();
m_pAccessMutex.unlock();
while( removeAt( cursor ) ); while( removeAt( cursor ) );
}; };

Loading…
Cancel
Save