mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
fixed memory leak in cap_libv4l.cpp (ticket #1518; thanks to gorgen for the patch)
This commit is contained in:
parent
951a3d6c7a
commit
403a7ff391
@ -821,6 +821,11 @@ static int _capture_V4L2 (CvCaptureCAM_V4L *capture, char *deviceName)
|
|||||||
|
|
||||||
#ifdef USE_TEMP_BUFFER
|
#ifdef USE_TEMP_BUFFER
|
||||||
if (n_buffers == 0) {
|
if (n_buffers == 0) {
|
||||||
|
if (capture->buffers[MAX_V4L_BUFFERS].start) {
|
||||||
|
free(capture->buffers[MAX_V4L_BUFFERS].start);
|
||||||
|
capture->buffers[MAX_V4L_BUFFERS].start = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
capture->buffers[MAX_V4L_BUFFERS].start = malloc(buf.length);
|
capture->buffers[MAX_V4L_BUFFERS].start = malloc(buf.length);
|
||||||
capture->buffers[MAX_V4L_BUFFERS].length = buf.length;
|
capture->buffers[MAX_V4L_BUFFERS].length = buf.length;
|
||||||
};
|
};
|
||||||
@ -1006,6 +1011,10 @@ static CvCaptureCAM_V4L * icvCaptureFromCAM_V4L (int index)
|
|||||||
capture->width = DEFAULT_V4L_WIDTH;
|
capture->width = DEFAULT_V4L_WIDTH;
|
||||||
capture->height = DEFAULT_V4L_HEIGHT;
|
capture->height = DEFAULT_V4L_HEIGHT;
|
||||||
|
|
||||||
|
#ifdef USE_TEMP_BUFFER
|
||||||
|
capture->buffers[MAX_V4L_BUFFERS].start = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Select camera, or rather, V4L video source */
|
/* Select camera, or rather, V4L video source */
|
||||||
if (index<0) { // Asking for the first device available
|
if (index<0) { // Asking for the first device available
|
||||||
for (; autoindex<MAX_CAMERAS;autoindex++)
|
for (; autoindex<MAX_CAMERAS;autoindex++)
|
||||||
@ -1184,7 +1193,6 @@ static int icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* preparation is ok */
|
/* preparation is ok */
|
||||||
capture->FirstCapture = 0;
|
capture->FirstCapture = 0;
|
||||||
}
|
}
|
||||||
@ -1694,6 +1702,13 @@ static void icvCloseCAM_V4L( CvCaptureCAM_V4L* capture ){
|
|||||||
if (capture->frame.imageData)
|
if (capture->frame.imageData)
|
||||||
cvFree(&capture->frame.imageData);
|
cvFree(&capture->frame.imageData);
|
||||||
|
|
||||||
|
#ifdef USE_TEMP_BUFFER
|
||||||
|
if (capture->buffers[MAX_V4L_BUFFERS].start) {
|
||||||
|
free(capture->buffers[MAX_V4L_BUFFERS].start);
|
||||||
|
capture->buffers[MAX_V4L_BUFFERS].start = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//v4l2_free_ranges(capture);
|
//v4l2_free_ranges(capture);
|
||||||
//cvFree((void **)capture);
|
//cvFree((void **)capture);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user