OSSP CVS Repository

ossp - Difference in ossp-pkg/mm/mm_alloc.c versions 1.20 and 1.21
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/mm/mm_alloc.c 1.20 -> 1.21

--- mm_alloc.c   2004/11/15 16:48:06     1.20
+++ mm_alloc.c   2005/09/02 19:50:34     1.21
@@ -188,13 +188,17 @@
 {
     mem_chunk *mc;
     mem_chunk *mcPrev;
+    mem_chunk *mcPrevPrev;
     mem_chunk *mcNext;
 
     if (!mm_core_lock((void *)mm, MM_LOCK_RW))
         return;
     mc = &(mm->mp_freechunks);
-    while (mc->mc_u.mc_next != NULL && (char *)(mc->mc_u.mc_next) < (char *)mcInsert)
+    mcPrevPrev = mc;
+    while (mc->mc_u.mc_next != NULL && (char *)(mc->mc_u.mc_next) < (char *)mcInsert) {
+        mcPrevPrev = mc;
         mc = mc->mc_u.mc_next;
+    }
     mcPrev = mc;
     mcNext = mc->mc_u.mc_next;
     if (mcPrev == mcInsert || mcNext == mcInsert) {
@@ -209,6 +213,13 @@
         mcPrev->mc_u.mc_next = mcNext->mc_u.mc_next;
         mm->mp_freechunks.mc_usize -= 1;
     }
+    else if ((char *)mcPrev+(mcPrev->mc_size) == (char *)mcInsert &&
+             (char *)mcInsert+(mcInsert->mc_size) == ((char *)mm + mm->mp_offset)) {
+        /* merge with previous and spare block (to increase spare area) */
+        mcPrevPrev->mc_u.mc_next = mcPrev->mc_u.mc_next;
+        mm->mp_offset -= (mcInsert->mc_size + mcPrev->mc_size);
+        mm->mp_freechunks.mc_usize -= 1;
+    }
     else if ((char *)mcPrev+(mcPrev->mc_size) == (char *)mcInsert) {
         /* merge with previous chunk */
         mcPrev->mc_size += mcInsert->mc_size;
@@ -219,6 +230,10 @@
         mcInsert->mc_u.mc_next = mcNext->mc_u.mc_next;
         mcPrev->mc_u.mc_next = mcInsert;
     }
+    else if ((char *)mcInsert+(mcInsert->mc_size) == ((char *)mm + mm->mp_offset)) {
+        /* merge with spare block (to increase spare area) */
+        mm->mp_offset -= mcInsert->mc_size;
+    }
     else {
         /* no merging possible, so insert as new chunk */
         mcInsert->mc_u.mc_next = mcNext;

CVSTrac 2.0.1