Skip to content

Commit 87b87d8

Browse files
committed
Removed memory leakages.
1 parent cf38808 commit 87b87d8

File tree

5 files changed

+103
-128
lines changed

5 files changed

+103
-128
lines changed

gft/gft.c

+4
Original file line numberDiff line numberDiff line change
@@ -3384,6 +3384,10 @@ static int mst_gen_destr(mst_gen *mst_genv)
33843384
FREE_COND(mst_genv -> nopar);
33853385
FREE_COND(mst_genv -> nospar);
33863386
FREE_COND(mst_genv -> nodpar);
3387+
FREE_COND(mst_genv -> nolbounds);
3388+
FREE_COND(mst_genv -> noubounds);
3389+
FREE_COND(mst_genv -> lbounds);
3390+
FREE_COND(mst_genv -> ubounds);
33873391

33883392
free(mst_genv);
33893393

src/cubarithm.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -1029,9 +1029,13 @@ void cubarithm_cube_destroy(Cube *cubev)
10291029
if (cubev -> type) free(cubev -> type);
10301030
if (cubev -> unit) free(cubev -> unit);
10311031

1032+
/* GJnew */
1033+
if (cubev -> header) qfits_header_destroy(cubev -> header);
10321034
if (cubev -> asciiheader) free(cubev -> asciiheader);
10331035
if (cubev -> points) fftwf_free(cubev -> points);
1034-
if (cubev -> wcs) wcsvfree(&(cubev -> nwcs), (struct wcsprm **) &(cubev -> wcs));
1036+
if (cubev -> wcs) {
1037+
wcsvfree(&(cubev -> nwcs), (struct wcsprm **) &(cubev -> wcs));
1038+
}
10351039
free(cubev);
10361040

10371041
return;
@@ -1590,7 +1594,7 @@ int cubarithm_readcube(const char *filename, Cube **cubename, char *errorstr)
15901594
cubenamehook -> nwcs = 0;
15911595

15921596
/* Enable error messaging */
1593-
wcserr_enable(1);
1597+
/* wcserr_enable(1); */
15941598

15951599
if (wcspih(cubenamehook -> asciiheader, cubenamehook -> header -> n, WCSHDR_all, 2, &nreject, &(cubenamehook -> nwcs), (struct wcsprm **) &(cubenamehook -> wcs))) {
15961600
wcsperr((struct wcsprm *) (cubenamehook -> wcs),"WCS error:");
@@ -1788,7 +1792,7 @@ Cube *cubarithm_copycube(Cube *incubus)
17881792
cpc -> nwcs = 0;
17891793

17901794
/* Enable error messaging */
1791-
wcserr_enable(1);
1795+
/* wcserr_enable(1); */
17921796

17931797
/* fprintf(stderr,"cpc -> asciiheader:\n|%s|\nincubus -> asciiheader:\n|%s|\nheader -> n %i\nheaderbytes: %i", incubus -> asciiheader, cpc -> asciiheader, cpc -> header -> n, (int) cpc -> headerbytes); */
17941798

src/ftstab.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -3543,9 +3543,9 @@ char *ftstab_gltitl(int titl)
35433543
if (!(gtitl = (char *) malloc(21*sizeof(char))))
35443544
return NULL;
35453545
if (ftstab_putlcoltitl(gtitl, titl) == -1) {
3546-
free(gtitl);
3547-
return NULL;
3548-
}
3546+
free(gtitl);
3547+
return NULL;
3548+
}
35493549
else
35503550
return gtitl;
35513551
}
@@ -3694,11 +3694,13 @@ int ftstab_gltitln_(char *titl)
36943694
if (!(dummy = ftstab_gltitl(i)))
36953695
return -1;
36963696

3697-
if (!strcmp(dummy, titl))
3697+
if (!strcmp(dummy, titl)) {
3698+
free(dummy);
36983699
break;
3699-
}
3700-
if (dummy)
3700+
}
3701+
37013702
free(dummy);
3703+
}
37023704

37033705
if (i == hdrlist_.n)
37043706
return -1;

src/simparse.c

+27-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Revision 1.5 2010/02/17 01:21:40 jozsa
2424
finished decomp complex
2525
26-
Revision 1.4 2009/06/19 17:31:59 jozsa
26+
Revision 1.4 2009/06/19 17:31:59 jozsa
2727
Bug removal evaluating the sep option in parsenext
2828
2929
Revision 1.3 2009/03/27 11:17:12 jozsa
@@ -3457,6 +3457,7 @@ static void simparse_scn_keyvalli_dest(simparse_scn_keyvalli *simparse_scn_keyva
34573457
if ((simparse_scn_keyvalliv -> val))
34583458
free(simparse_scn_keyvalliv -> val);
34593459

3460+
/* GJnew */
34603461
free(simparse_scn_keyvalliv);
34613462

34623463
return;
@@ -3635,7 +3636,7 @@ static simparse_scn_keyvalli **simparse_scn_keyvallilist_gcomm(char **readin)
36353636

36363637
while ((readin[i])) {
36373638

3638-
/* printf("The line to be hacked: |%s|\n", readin[i]); */
3639+
/* printf("The line to be hacked: |%s|\n", readin[i]); */
36393640

36403641
hacked = sparsenext(" \n\t", "", "", "", "", "", -1, &(readin[i]), &line, 1, 1);
36413642

@@ -3686,26 +3687,35 @@ static simparse_scn_keyvalli **simparse_scn_keyvallilist_gcomm(char **readin)
36863687
tempval = simparse_copystring("");
36873688
}
36883689

3689-
if (!(readin[i+1]))
3690+
if (!(readin[i+1])) {
3691+
if ((tempval))
3692+
free(tempval);
36903693
if (!(tempval = simparse_copystring(readin[i])))
36913694
goto error;
3692-
3695+
}
36933696

36943697
if ((tempkey)) {
36953698
/* printf("########################\nkey: |%s| val: |%s| line: |%i|\n", tempkey, tempval, citeline); */
36963699

36973700
/* Append to list */
36983701
if (!(simparse_scn_keyvallilist_gcomm = simparse_scn_keyvalli_insert(simparse_scn_keyvallilist_gcomm, tempkey, tempval, citeline)))
36993702
goto error;
3703+
3704+
/* GJnew */
3705+
free(tempkey);
37003706
}
37013707
tempkey = tempkeynext;
37023708
tempkeynext = NULL;
37033709
citeline = line;
37043710
/* printf("\n"); */
37053711
freeparsed(hacked);
3712+
3713+
/* GJnew */
3714+
free(tempval);
37063715
++i;
37073716
}
3708-
3717+
if ((tempkey))
3718+
free(tempkey);
37093719
return simparse_scn_keyvallilist_gcomm;
37103720

37113721
error:
@@ -3835,6 +3845,8 @@ void simparse_scn_keyvallilist_dest(simparse_scn_keyvalli **simparse_scn_keyvall
38353845
++i;
38363846
}
38373847

3848+
free(simparse_scn_keyvallilist);
3849+
38383850
return;
38393851
}
38403852

@@ -3888,6 +3900,9 @@ static void simparse_scn_arel_dest(simparse_scn_arel *simparse_scn_arelv)
38883900

38893901
simparse_scn_keyvallilist_dest(simparse_scn_arelv -> keyvallifile);
38903902

3903+
/* GJnew */
3904+
free(simparse_scn_arelv);
3905+
38913906
return;
38923907
}
38933908

@@ -3929,6 +3944,8 @@ void simparse_scn_arellist_dest(simparse_scn_arel **simparse_scn_arellist)
39293944
++i;
39303945
}
39313946

3947+
free(simparse_scn_arellist);
3948+
39323949
return;
39333950
}
39343951

@@ -4053,7 +4070,7 @@ int simparse_scn_arel_upd(simparse_scn_arel *simparse_scn_arelv)
40534070
}
40544071
else {
40554072
if (!(keyvallifile = simparse_scn_keyvallilist_start()))
4056-
goto error;
4073+
goto error;
40574074
action_file = 1;
40584075
}
40594076
}
@@ -4062,6 +4079,7 @@ int simparse_scn_arel_upd(simparse_scn_arel *simparse_scn_arelv)
40624079
goto error;
40634080
action_file = 1;
40644081
}
4082+
40654083
/* Do replacing and linking */
40664084
if ((action_pre)) {
40674085
simparse_scn_keyvallilist_dest(simparse_scn_arelv -> keyvallipre);
@@ -5104,6 +5122,9 @@ int simparse_scn_arel_readval_gen(simparse_scn_arel **simparse_scn_arellist, cha
51045122
}
51055123

51065124
/* Deallocate stuff */
5125+
/* if (intreturn)
5126+
free(intreturn); */
5127+
51075128
if ((valintern))
51085129
free(valintern);
51095130
valintern = NULL;

0 commit comments

Comments
 (0)