Changeset 607


Ignore:
Timestamp:
May 19, 2015 5:36:56 AM (4 years ago)
Author:
kulshres
Message:

fix a memory leak in the buffer destructor

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ADOL-C/src/buffer_temp.h

    r600 r607  
    4141        SubBufferElement elements[_subBufferSize];
    4242        struct SubBuffer *nextSubBuffer;
     43        SubBuffer();
    4344    }
    4445    SubBuffer;
     
    7879
    7980BUFFER_TEMPLATE
     81BUFFER::SubBuffer::SubBuffer() {
     82   memset(elements,0,sizeof(SubBufferElement)*_subBufferSize);
     83   nextSubBuffer = NULL;
     84}
     85
     86BUFFER_TEMPLATE
    8087BUFFER::~Buffer() {
    8188    SubBuffer *tmpSubBuffer = NULL;
     
    8491        tmpSubBuffer = firstSubBuffer;
    8592        firstSubBuffer = firstSubBuffer->nextSubBuffer;
     93        for(int i = 0; i < subBufferSize; i++)
     94            if (tmpSubBuffer->elements[i].allmem != NULL)
     95                free(tmpSubBuffer->elements[i].allmem);
    8696        delete tmpSubBuffer;
    8797    }
Note: See TracChangeset for help on using the changeset viewer.