nbis: Use GLib memory management functions

Apply the previously added spatch/coccinell file to replace all
free/malloc/realloc calls with g_free/g_malloc/g_realloc. It also removes
all the error code paths that we do not need to check anymore.

This means that the returned data must be free'ed using g_free rather
than free, making memory management more consistent.
This commit is contained in:
Benjamin Berg
2019-06-27 19:21:17 +02:00
committed by Marco Trevisan (Treviño)
parent 56543e1311
commit 30a449841c
20 changed files with 273 additions and 628 deletions

View File

@@ -100,12 +100,7 @@ int chain_code_loop(int **ochain, int *onchain,
/* number of points in the contour. There will be one chain code */
/* between each point on the contour including a code between the */
/* last to the first point on the contour (completing the loop). */
chain = (int *)malloc(ncontour * sizeof(int));
/* If the allocation fails ... */
if(chain == (int *)NULL){
fprintf(stderr, "ERROR : chain_code_loop : malloc : chain\n");
return(-170);
}
chain = (int *)g_malloc(ncontour * sizeof(int));
/* For each neighboring point in the list (with "i" pointing to the */
/* previous neighbor and "j" pointing to the next neighbor... */