properly check for return value of mem_sbrk
This commit is contained in:
parent
e4275ea995
commit
cedb5d607c
@ -145,7 +145,7 @@ int mm_init(void)
|
|||||||
|
|
||||||
/* Create the initial empty heap */
|
/* Create the initial empty heap */
|
||||||
struct boundary_tag * initial = mem_sbrk(4 * sizeof(struct boundary_tag));
|
struct boundary_tag * initial = mem_sbrk(4 * sizeof(struct boundary_tag));
|
||||||
if (initial == (void *)-1)
|
if (initial == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* We use a slightly different strategy than suggested in the book.
|
/* We use a slightly different strategy than suggested in the book.
|
||||||
@ -302,7 +302,7 @@ static struct block *extend_heap(size_t words)
|
|||||||
{
|
{
|
||||||
void *bp = mem_sbrk(words * WSIZE);
|
void *bp = mem_sbrk(words * WSIZE);
|
||||||
|
|
||||||
if ((intptr_t) bp == -1)
|
if (bp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Initialize free block header/footer and the epilogue header.
|
/* Initialize free block header/footer and the epilogue header.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user