Fix to prevent reporting out of memory when there should be plenty of

2007-12-11  Kevin Cozens  <kcozens@cvs.gnome.org>

	* plug-ins/script-fu/tinyscheme/scheme.c (get_consecutive_cells):
	Fix to prevent reporting out of memory when there should be plenty
	of cells still available. See SourceForge bug #1794369.

svn path=/trunk/; revision=24328
This commit is contained in:
Kevin Cozens
2007-12-12 03:11:16 +00:00
committed by Kevin Cozens
parent 8a685dd322
commit 916e4d4f78
2 changed files with 24 additions and 19 deletions

View File

@ -1,3 +1,9 @@
2007-12-11 Kevin Cozens <kcozens@cvs.gnome.org>
* plug-ins/script-fu/tinyscheme/scheme.c (get_consecutive_cells):
Fix to prevent reporting out of memory when there should be plenty
of cells still available. See SourceForge bug #1794369.
2007-12-11 Kevin Cozens <kcozens@cvs.gnome.org> 2007-12-11 Kevin Cozens <kcozens@cvs.gnome.org>
* plug-ins/script-fu/tinyscheme/scheme.c: Don't abort the top-level * plug-ins/script-fu/tinyscheme/scheme.c: Don't abort the top-level

View File

@ -723,31 +723,30 @@ static pointer reserve_cells(scheme *sc, int n) {
static pointer get_consecutive_cells(scheme *sc, int n) { static pointer get_consecutive_cells(scheme *sc, int n) {
pointer x; pointer x;
if(sc->no_memory) { if (sc->no_memory) { return sc->sink; }
return sc->sink;
}
/* Are there any cells available? */ /* Are there any cells available? */
x=find_consecutive_cells(sc,n); x=find_consecutive_cells(sc,n);
if (x == sc->NIL) { if (x != sc->NIL) { return x; }
/* If not, try gc'ing some */
gc(sc, sc->NIL, sc->NIL); /* If not, try gc'ing some */
x=find_consecutive_cells(sc,n); gc(sc, sc->NIL, sc->NIL);
if (x == sc->NIL) { x=find_consecutive_cells(sc,n);
/* If there still aren't, try getting more heap */ if (x != sc->NIL) { return x; }
if (!alloc_cellseg(sc,1)) {
sc->no_memory=1; /* If there still aren't, try getting more heap */
return sc->sink; if (!alloc_cellseg(sc,1))
} {
}
x=find_consecutive_cells(sc,n);
if (x == sc->NIL) {
/* If all fail, report failure */
sc->no_memory=1; sc->no_memory=1;
return sc->sink; return sc->sink;
} }
}
return (x); x=find_consecutive_cells(sc,n);
if (x != sc->NIL) { return x; }
/* If all fail, report failure */
sc->no_memory=1;
return sc->sink;
} }
static int count_consecutive_cells(pointer x, int needed) { static int count_consecutive_cells(pointer x, int needed) {