aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-11-18 09:01:23 -0600
committerMatt Strapp <strap012@umn.edu>2020-11-18 09:01:23 -0600
commit1f081d9c1457acf140f686fc9b19ab36e34b0bf8 (patch)
tree3cfb6608b533e902e3a04a34f7c799a7c63b0a87
parentno longer leaking like a sieve but still leaky (diff)
downloadcsci4061-1f081d9c1457acf140f686fc9b19ab36e34b0bf8.tar
csci4061-1f081d9c1457acf140f686fc9b19ab36e34b0bf8.tar.gz
csci4061-1f081d9c1457acf140f686fc9b19ab36e34b0bf8.tar.bz2
csci4061-1f081d9c1457acf140f686fc9b19ab36e34b0bf8.tar.lz
csci4061-1f081d9c1457acf140f686fc9b19ab36e34b0bf8.tar.xz
csci4061-1f081d9c1457acf140f686fc9b19ab36e34b0bf8.tar.zst
csci4061-1f081d9c1457acf140f686fc9b19ab36e34b0bf8.zip
valrgind still sad
-rw-r--r--P3/server.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/P3/server.c b/P3/server.c
index 43c0a08..8838293 100644
--- a/P3/server.c
+++ b/P3/server.c
@@ -178,10 +178,11 @@ void * dispatch(void *arg) {
if (traverse == NULL) {
//Add things to queue. Lock & unlock to prevent a deadlock
pthread_mutex_lock(&Qlock);
- request_t * tempNode = (request_t*) malloc(sizeof(request_t));
+ request_t *tempNode = (request_t *)calloc(1, sizeof(request_t));
char* dispatchBuf = (char *) malloc(BUFF_SIZE); // Buffer to store the requested filename
if (get_request(newReq, dispatchBuf) != 0) {
pthread_mutex_unlock(&Qlock);
+ free(tempNode);
free(dispatchBuf);
continue; // If get_request fails, try again
}
@@ -224,7 +225,7 @@ void * worker(void *arg) {
// TODO! Get the data from the disk or the cache (extra credit B)
numbytes = getFileSize(request->request);
- char *workerBuf = (char *)calloc(numbytes, sizeof(char));
+ char *workerBuf = (char *) malloc(numbytes*sizeof(char));
char *bytesError = malloc(BUFF_SIZE);
if (numbytes != 0) {
//SUCC