Skip to content

Commit

Permalink
fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
mpromonet committed May 4, 2024
1 parent ef86de3 commit ce80891
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion libv4l2cpp
30 changes: 12 additions & 18 deletions src/V4L2DeviceSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,20 @@ void* V4L2DeviceSource::thread()
int ret = select(fd+1, &fdset, NULL, NULL, &tv);
if (ret == 1)
{
if (FD_ISSET(fd, &fdset))
LOG(DEBUG) << "waitingFrame\tdelay:" << (1000-(tv.tv_usec/1000)) << "ms";
if (this->getNextFrame() <= 0)
{
LOG(DEBUG) << "waitingFrame\tdelay:" << (1000-(tv.tv_usec/1000)) << "ms";
if (this->getNextFrame() <= 0)
if (errno == EAGAIN)
{
if (errno == EAGAIN)
{
LOG(NOTICE) << "Retrying getNextFrame";
}
else
{
LOG(ERROR) << "error:" << strerror(errno);
stop=1;
}
LOG(DEBUG) << "Retrying getNextFrame";
}
else
{
LOG(ERROR) << "error:" << strerror(errno);
stop=1;
}
}
}
else if (ret == -1)
{
LOG(ERROR) << "stop " << strerror(errno);
stop=1;
}
}
LOG(NOTICE) << "end thread";
return NULL;
Expand Down Expand Up @@ -208,10 +200,12 @@ int V4L2DeviceSource::getNextFrame()
if (frameSize < 0)
{
LOG(NOTICE) << "V4L2DeviceSource::getNextFrame errno:" << errno << " " << strerror(errno);
delete [] buffer;
}
else if (frameSize == 0)
{
LOG(NOTICE) << "V4L2DeviceSource::getNextFrame no data errno:" << errno << " " << strerror(errno);
LOG(DEBUG) << "V4L2DeviceSource::getNextFrame no data errno:" << errno << " " << strerror(errno);
delete [] buffer;
}
else
{
Expand Down

0 comments on commit ce80891

Please sign in to comment.