projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rename printk() to printf().
[pintos-anon]
/
src
/
threads
/
malloc.c
diff --git
a/src/threads/malloc.c
b/src/threads/malloc.c
index 02eee99fca15b47eed79863a08f7765b5c5ce533..441ae59a0bfdaa2216c264bfaed51eeefb2d569c 100644
(file)
--- a/
src/threads/malloc.c
+++ b/
src/threads/malloc.c
@@
-1,11
+1,12
@@
-#include "malloc.h"
+#include "threads/malloc.h"
+#include <debug.h>
+#include <list.h>
#include <stdint.h>
#include <stdint.h>
-#include "debug.h"
-#include "lib.h"
-#include "list.h"
-#include "synch.h"
-#include "mmu.h"
-#include "palloc.h"
+#include <stdio.h>
+#include <string.h>
+#include "threads/mmu.h"
+#include "threads/palloc.h"
+#include "threads/synch.h"
/* A simple implementation of malloc().
/* A simple implementation of malloc().
@@
-97,7
+98,7
@@
malloc (size_t size)
break;
if (d == descs + desc_cnt)
{
break;
if (d == descs + desc_cnt)
{
- print
k
("malloc: %zu byte allocation too big\n", size);
+ print
f
("malloc: %zu byte allocation too big\n", size);
return NULL;
}
return NULL;
}
@@
-164,6
+165,9
@@
free (void *p)
struct arena *a = block_to_arena (b);
struct desc *d = a->desc;
struct arena *a = block_to_arena (b);
struct desc *d = a->desc;
+ if (p == NULL)
+ return;
+
lock_acquire (&d->lock);
/* Add block to free list. */
lock_acquire (&d->lock);
/* Add block to free list. */