mirror of
https://github.com/bspeice/libcvautomation
synced 2025-04-21 00:41:29 -04:00
Fix memory management of the linked list.
This commit is contained in:
parent
84212eb006
commit
ab5ab77f32
@ -47,7 +47,7 @@ int main( int argc, char** argv )
|
|||||||
char *xDisplay;
|
char *xDisplay;
|
||||||
|
|
||||||
/* Set up the linked list for slave images */
|
/* Set up the linked list for slave images */
|
||||||
basic_list *list_head = NULL, *list_curr = NULL;
|
basic_list *list_head = NULL, *list_curr = NULL, *list_prev = NULL;
|
||||||
|
|
||||||
/* Start getopt */
|
/* Start getopt */
|
||||||
while (1)
|
while (1)
|
||||||
@ -158,11 +158,17 @@ int main( int argc, char** argv )
|
|||||||
result_point.x, separator, result_point.y );
|
result_point.x, separator, result_point.y );
|
||||||
|
|
||||||
/* With the way we allocate the list, we ensure that we always
|
/* With the way we allocate the list, we ensure that we always
|
||||||
* have at least one element past the end of the list */
|
* have at least one element past the end of the list.
|
||||||
|
* Also, deconstruct the list as we go. */
|
||||||
|
list_prev = list_curr;
|
||||||
list_curr = list_curr->next;
|
list_curr = list_curr->next;
|
||||||
|
free(list_prev);
|
||||||
|
|
||||||
} while ( list_curr->fileName != NULL );
|
} while ( list_curr->fileName != NULL );
|
||||||
|
|
||||||
|
/* And free the final element */
|
||||||
|
free(list_curr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user