From cedb5d607c771f13b37018734910335be82eff8e Mon Sep 17 00:00:00 2001 From: Godmar Back Date: Fri, 28 Oct 2022 13:46:39 -0400 Subject: [PATCH] properly check for return value of mem_sbrk --- mm-gback-implicit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm-gback-implicit.c b/mm-gback-implicit.c index b35fdeb..1e64989 100644 --- a/mm-gback-implicit.c +++ b/mm-gback-implicit.c @@ -145,7 +145,7 @@ int mm_init(void) /* Create the initial empty heap */ struct boundary_tag * initial = mem_sbrk(4 * sizeof(struct boundary_tag)); - if (initial == (void *)-1) + if (initial == NULL) return -1; /* 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); - if ((intptr_t) bp == -1) + if (bp == NULL) return NULL; /* Initialize free block header/footer and the epilogue header.