Skip to content

Commit c4cff10

Browse files
committed
Fix some things
1 parent 1946bbd commit c4cff10

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

network/http.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ static void cerror(FILE *stream, char *cause, char *errno, char *shortm, char *l
7777

7878
static void serve_file(FILE *stream, struct stat *stat, char *filename) {
7979
char *p;
80-
//char filetype[BUFSIZE];
8180
char *filetype;
82-
filetype = (char *)malloc(BUFSIZE);
81+
filetype = (char *)malloc((sizeof(char) * BUFSIZE));
8382
for (int z = 0; z < sizeof(types); z++) {
8483
if (strstr(filename, types[z].extension)) {
8584
strcpy(filetype, types[z].type);
@@ -160,7 +159,7 @@ static void serve_directory(int cfd, char *filename) {
160159
}
161160
sprintf(buf, "</tbody></table></body></html>");
162161
write(cfd, buf, strlen(buf));
163-
//
162+
164163
free(buf);
165164
buf = NULL;
166165

thread/mutex.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ static void *handler(void *arg) {
1919
sleep(2);
2020
printf("Job %d has finished\n", counter);
2121
pthread_mutex_unlock(lock);
22+
pthread_exit(NULL);
2223
return NULL;
2324
}
2425

@@ -49,6 +50,7 @@ int main(void) {
4950
pthread_join(tid[i], NULL);
5051
}
5152

53+
pthread_exit(NULL);
5254
pthread_mutex_destroy(lock);
5355
free(lock);
5456
free(tid);

0 commit comments

Comments
 (0)