mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-22 09:32:53 -06:00
fix the memory allocator
This commit is contained in:
@@ -413,7 +413,7 @@ static void malloc_consolidate(malloc_state *ms)
|
|||||||
object* fb; /* current fastbin being consolidated */
|
object* fb; /* current fastbin being consolidated */
|
||||||
object* maxfb; /* last fastbin (for loop control) */
|
object* maxfb; /* last fastbin (for loop control) */
|
||||||
mchunk* p; /* current chunk being consolidated */
|
mchunk* p; /* current chunk being consolidated */
|
||||||
mchunk* nextp; /* next chunk to consolidate */
|
object next_fb; /* next chunk to consolidate */
|
||||||
mchunk* unsorted_bin; /* bin header */
|
mchunk* unsorted_bin; /* bin header */
|
||||||
mchunk* first_unsorted; /* chunk to link to */
|
mchunk* first_unsorted; /* chunk to link to */
|
||||||
/* These have same use as in free() */
|
/* These have same use as in free() */
|
||||||
@@ -435,11 +435,11 @@ static void malloc_consolidate(malloc_state *ms)
|
|||||||
maxfb = &ms->fastbins[NFASTBINS - 1];
|
maxfb = &ms->fastbins[NFASTBINS - 1];
|
||||||
fb = &ms->fastbins[0];
|
fb = &ms->fastbins[0];
|
||||||
do {
|
do {
|
||||||
|
if (*fb != 0) {
|
||||||
p = ptr(ms,*fb);
|
p = ptr(ms,*fb);
|
||||||
*fb = 0;
|
*fb = 0;
|
||||||
if (p != NULL) {
|
for (;;) {
|
||||||
do {
|
next_fb = p->fd;
|
||||||
nextp = ptr(ms,p->fd);
|
|
||||||
/* Slightly streamlined version of consolidation code in free() */
|
/* Slightly streamlined version of consolidation code in free() */
|
||||||
size = chunksize(p);
|
size = chunksize(p);
|
||||||
nextchunk = chunk_at_offset(p, size);
|
nextchunk = chunk_at_offset(p, size);
|
||||||
@@ -473,7 +473,11 @@ static void malloc_consolidate(malloc_state *ms)
|
|||||||
set_head(p, size | PREV_INUSE);
|
set_head(p, size | PREV_INUSE);
|
||||||
ms->top = ofs(ms,p);
|
ms->top = ofs(ms,p);
|
||||||
}
|
}
|
||||||
} while ((p = nextp) != 0);
|
|
||||||
|
if (next_fb == 0)
|
||||||
|
break;
|
||||||
|
p = ptr(ms,next_fb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (fb++ != maxfb);
|
} while (fb++ != maxfb);
|
||||||
}
|
}
|
||||||
@@ -863,7 +867,7 @@ DB::free_internal(object o)
|
|||||||
mchunk* bck; /* misc temp for linking */
|
mchunk* bck; /* misc temp for linking */
|
||||||
mchunk* fwd; /* misc temp for linking */
|
mchunk* fwd; /* misc temp for linking */
|
||||||
|
|
||||||
mchunk* p = ptr(ms,o);
|
mchunk* p = mem2chunk(ptr(ms,o));
|
||||||
size = chunksize(p);
|
size = chunksize(p);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user