From 03987ef3d1ed9c2d604561a69db169cd535014b6 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期六, 25 七月 2020 16:17:04 +0800
Subject: [PATCH] commit

---
 src/queue/mm.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/queue/mm.c b/src/queue/mm.c
index 592fda0..b09aa73 100644
--- a/src/queue/mm.c
+++ b/src/queue/mm.c
@@ -81,7 +81,7 @@
 static void *place(void *bp, size_t size);
 static void *find_fit(size_t size);
 static void *coalesce(void *bp);
-static void rm_fblock(void *bp);
+static inline void rm_fblock(void *bp);
 static void insert_fblock (void *bp);
 
 static void *mem_sbrk(int incr);
@@ -122,6 +122,7 @@
     SemUtil::inc(mutex);
     return aptr;
   } else {
+    SemUtil::inc(mutex);
     err_msg(0, "mm_malloc : out of memery\n");
     return NULL;
   }
@@ -143,9 +144,8 @@
    *}
    */
 
-  
-  size_t size = GET_SIZE(HDRP(ptr));
   SemUtil::dec(mutex);
+  size_t size = GET_SIZE(HDRP(ptr));
   PUT(HDRP(ptr), PACK(size, 0));
   PUT(FTRP(ptr), PACK(size, 0));
   coalesce(ptr);
@@ -444,9 +444,10 @@
 /**
  * remove a block form free list
  */
-static void rm_fblock(void *rbp)
+static inline void rm_fblock(void *rbp)
 {
   // the successor of the previous block of rbp point to next block of rbp
+
   PUT_PTR(SUCCRP(PREV_FBLKP(rbp)), NEXT_FBLKP(rbp));
   // the predecessor of then next block of rbp point to previous block of rbp
   PUT_PTR(PREDRP(NEXT_FBLKP(rbp)), PREV_FBLKP(rbp));

--
Gitblit v1.8.0