aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authoronefang2021-07-07 09:06:54 +1000
committeronefang2021-07-07 09:06:54 +1000
commitd4a7647ac13c74e89d83248687e755355bf14c29 (patch)
tree4a7743ab7adf584f800bd224f6a2ee8ab1eb4f21
parentwhitespace++ (diff)
downloadopensim-SC-d4a7647ac13c74e89d83248687e755355bf14c29.zip
opensim-SC-d4a7647ac13c74e89d83248687e755355bf14c29.tar.gz
opensim-SC-d4a7647ac13c74e89d83248687e755355bf14c29.tar.bz2
opensim-SC-d4a7647ac13c74e89d83248687e755355bf14c29.tar.xz
Various memory freeing stuff.
-rw-r--r--src/sledjchisl/sledjchisl.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c
index f395703..8ab41ab 100644
--- a/src/sledjchisl/sledjchisl.c
+++ b/src/sledjchisl/sledjchisl.c
@@ -820,8 +820,7 @@ simList *getSims()
820 { 820 {
821 char *sim = ourSims->sims[i], *name = xmprintf("%s/config/%s", scRoot, sim); 821 char *sim = ourSims->sims[i], *name = xmprintf("%s/config/%s", scRoot, sim);
822 qlisttbl_t *ini; 822 qlisttbl_t *ini;
823 simData *simd = xmalloc(sizeof(simData)); 823 simData *simd = xzalloc(sizeof(simData));
824
825 struct dirtree *new = dirtree_add_node(0, name, 0); 824 struct dirtree *new = dirtree_add_node(0, name, 0);
826 825
827 free(name); 826 free(name);
@@ -887,10 +886,12 @@ ourSims->tbl->put(ourSims->tbl, sim, ini, sizeof(qlisttbl_t));
887 } 886 }
888 free(cmd); 887 free(cmd);
889 } 888 }
889 free(ini);
890 free(newPath);
891 free(path);
890 } 892 }
891 free(newPath); 893 else
892 free(path); 894 free(name);
893
894 895
895 if (-1 != fd) 896 if (-1 != fd)
896 { 897 {
@@ -901,6 +902,7 @@ ourSims->tbl->put(ourSims->tbl, sim, ini, sizeof(qlisttbl_t));
901 free(tnm); 902 free(tnm);
902 } 903 }
903 904
905 free(simd);
904 } 906 }
905 907
906 if (-1 != fd) 908 if (-1 != fd)
@@ -914,7 +916,6 @@ ourSims->tbl->put(ourSims->tbl, sim, ini, sizeof(qlisttbl_t));
914 } 916 }
915 free(file); 917 free(file);
916 918
917
918 return ourSims; 919 return ourSims;
919} 920}
920 921
@@ -941,16 +942,18 @@ void freeSimList(simList *sims)
941 if (NULL != simd) 942 if (NULL != simd)
942 { 943 {
943 free(simd->name); 944 free(simd->name);
945 free(simd->tab);
944 free(simd->UUID); 946 free(simd->UUID);
945 free(simd->regionType); 947 free(simd->regionType);
946// free(simd->estate); 948 free(simd->estate);
947// free(simd->owner); 949 free(simd->owner);
948 free(simd); 950 free(simd);
949 } 951 }
950// TODO - this leaks memory, but it's a bug in qLibc. Send the bug fix upstream. 952// TODO - this leaks memory, but it's a bug in qLibc. Send the bug fix upstream.
951// It either leaks, or frees twice. Pffft 953// It either leaks, or frees twice. Pffft
952// ini->clear(ini); 954// ini->clear(ini);
953// ini->free(ini); 955// ini->free(ini);
956// free(ini);
954 ; 957 ;
955 } 958 }
956 959
@@ -961,6 +964,30 @@ void freeSimList(simList *sims)
961 sims->tbl->unlock(sims->tbl); 964 sims->tbl->unlock(sims->tbl);
962 sims->tbl->free(sims->tbl); 965 sims->tbl->free(sims->tbl);
963 966
967 memset((void*) &obj, 0, sizeof(obj)); // start from the minimum.
968 sims->byTab->lock(sims->byTab);
969 while (sims->byTab->getnext(sims->byTab, &obj, false) == true)
970 {
971 char *name = qmemdup(obj.name, obj.namesize); // keep the name
972 size_t namesize = obj.namesize; // for removal argument
973 qlisttbl_t *ini = (qlisttbl_t *) obj.data;
974 if (NULL != ini)
975 {
976// TODO - this leaks memory, but it's a bug in qLibc. Send the bug fix upstream.
977// It either leaks, or frees twice. Pffft
978// ini->clear(ini);
979// ini->free(ini);
980// free(ini);
981 ;
982 }
983
984 sims->byTab->remove_by_obj(sims->byTab, obj.name, obj.namesize); // remove
985 obj = sims->byTab->find_nearest(sims->byTab, name, namesize, false); // rewind one step back
986 free(name); // clean up
987 }
988 sims->byTab->unlock(sims->byTab);
989 sims->byTab->free(sims->byTab);
990
964 free(sims); 991 free(sims);
965} 992}
966 993
@@ -1006,6 +1033,8 @@ int checkSimIsRunning(char *sim)
1006 else 1033 else
1007 d("checkSimIsRunning(%s) has PID %s, which is actually running.", sim, pid); 1034 d("checkSimIsRunning(%s) has PID %s, which is actually running.", sim, pid);
1008 } 1035 }
1036// TODO - WTF?
1037// free(path);
1009 } 1038 }
1010 } 1039 }
1011 free(pid); 1040 free(pid);
@@ -6871,6 +6900,7 @@ jit library is loaded or the JIT compiler will not be activated.
6871 // Don't want it in the path. 6900 // Don't want it in the path.
6872 // Could put the .dlls into lib. Most of the rest is config files or common assets. 6901 // Could put the .dlls into lib. Most of the rest is config files or common assets.
6873 // Or just slowly migrate opensim stuff to FHS. 6902 // Or just slowly migrate opensim stuff to FHS.
6903// TODO - free these. Though valgrind isn't bitching about them.
6874 scBin = xmprintf("%s%s/bin", slsh, scRoot); 6904 scBin = xmprintf("%s%s/bin", slsh, scRoot);
6875 scEtc = xmprintf("%s%s/etc", slsh, scRoot); 6905 scEtc = xmprintf("%s%s/etc", slsh, scRoot);
6876 scLib = xmprintf("%s%s/lib", slsh, scRoot); 6906 scLib = xmprintf("%s%s/lib", slsh, scRoot);
@@ -7640,6 +7670,8 @@ sims = -- Note these are .shini / tmux tab short names.
7640 I("Not waiting for %s to finish starting up.", name); 7670 I("Not waiting for %s to finish starting up.", name);
7641 count++; 7671 count++;
7642 } 7672 }
7673 free(newPath);
7674 free(path);
7643 } 7675 }
7644 break; 7676 break;
7645 } 7677 }
@@ -7813,6 +7845,7 @@ nextSim:
7813 7845
7814finished: 7846finished:
7815 freeSimList(ourSims); 7847 freeSimList(ourSims);
7848 ourSims = NULL;
7816 7849
7817 // An example of calling a toy directly. 7850 // An example of calling a toy directly.
7818// printf("\n\n"); 7851// printf("\n\n");