summaryrefslogtreecommitdiffstats
path: root/hw2
diff options
context:
space:
mode:
authorLAN-TW <lantw44@gmail.com>2013-11-16 20:56:27 +0800
committerLAN-TW <lantw44@gmail.com>2013-11-16 20:56:27 +0800
commit2dddeef2f0e44283d704fb692782aadc1b61bb71 (patch)
tree2447f8f1d70624544486828381b54abc3ae21efe /hw2
parent64709def2a772a82b9130c6f73c6774bcc29bf5d (diff)
downloadsp2013-2dddeef2f0e44283d704fb692782aadc1b61bb71.tar
sp2013-2dddeef2f0e44283d704fb692782aadc1b61bb71.tar.gz
sp2013-2dddeef2f0e44283d704fb692782aadc1b61bb71.tar.bz2
sp2013-2dddeef2f0e44283d704fb692782aadc1b61bb71.tar.lz
sp2013-2dddeef2f0e44283d704fb692782aadc1b61bb71.tar.xz
sp2013-2dddeef2f0e44283d704fb692782aadc1b61bb71.tar.zst
sp2013-2dddeef2f0e44283d704fb692782aadc1b61bb71.zip
HW2: 修正簡單的記憶體存取問題
Diffstat (limited to 'hw2')
-rw-r--r--hw2/big_judge.c4
-rw-r--r--hw2/player.c5
2 files changed, 8 insertions, 1 deletions
diff --git a/hw2/big_judge.c b/hw2/big_judge.c
index 7c029c0..f387dca 100644
--- a/hw2/big_judge.c
+++ b/hw2/big_judge.c
@@ -259,6 +259,10 @@ int main (int argc, char* argv[]) {
i + 1, pd[i].id, pd[i].score);
}
+ free (jd);
+ free (pd);
+ free (jpoll);
+
comp135_destroy (comp);
return 0;
diff --git a/hw2/player.c b/hw2/player.c
index 03a2f58..f6d69bf 100644
--- a/hw2/player.c
+++ b/hw2/player.c
@@ -30,7 +30,7 @@ int main (int argc, char* argv[]) {
FILE* rf = NULL;
FILE* wf = NULL;
char* fifoname;
- int oth[4];
+ int oth[4] = { 0, 0, 0, 0 };
int cnt[3] = { 0, 0, 0 };
int i = 0;
@@ -81,5 +81,8 @@ int main (int argc, char* argv[]) {
}
} while (++i < 20 && fscanf (rf, "%d %d %d %d", &oth[0], &oth[1], &oth[2], &oth[3]) == 4);
+ fclose (rf);
+ fclose (wf);
+
return 0;
}