Applied changes from official version of TinyScheme which adds tests for

2008-09-14  Kevin Cozens  <kcozens@cvs.gnome.org>

	* plug-ins/script-fu/tinyscheme/scheme.c (mk_vector), (opexe_2):
	Applied changes from official version of TinyScheme which adds
	tests for when mk_vector is out of memory. Can't rely on sc->sink.

svn path=/trunk/; revision=26943
This commit is contained in:
Kevin Cozens
2008-09-14 22:59:06 +00:00
committed by Kevin Cozens
parent 460b0ffbfd
commit 600274e85d
2 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2008-09-14 Kevin Cozens <kcozens@cvs.gnome.org>
* plug-ins/script-fu/tinyscheme/scheme.c (mk_vector), (opexe_2):
Applied changes from official version of TinyScheme which adds
tests for when mk_vector is out of memory. Can't rely on sc->sink.
2008-09-13 Michael Schumacher <schumaml@cvs.gnome.org> 2008-09-13 Michael Schumacher <schumaml@cvs.gnome.org>
* app/actions/edit-actions.c (edit_actions): removed double "the" * app/actions/edit-actions.c (edit_actions): removed double "the"
@ -11,7 +17,7 @@
2008-09-12 Kevin Cozens <kcozens@cvs.gnome.org> 2008-09-12 Kevin Cozens <kcozens@cvs.gnome.org>
* plug-ins/script-fu/tinyscheme/scheme.c * plug-ins/script-fu/tinyscheme/scheme.c
* plug-ins/script-fu/tinyscheme/scheme.h: Applied changes froh * plug-ins/script-fu/tinyscheme/scheme.h: Applied changes from
official version of TinyScheme which expose more of the internals. official version of TinyScheme which expose more of the internals.
Part of making it more suitable for Scheme->C->Scheme calling. Part of making it more suitable for Scheme->C->Scheme calling.
See SourceForge bug #1599947. See SourceForge bug #1599947.

View File

@ -1026,6 +1026,7 @@ INTERFACE pointer mk_empty_string(scheme *sc, int len, gunichar fill) {
INTERFACE static pointer mk_vector(scheme *sc, int len) { INTERFACE static pointer mk_vector(scheme *sc, int len) {
pointer x=get_consecutive_cells(sc,len/2+len%2+1); pointer x=get_consecutive_cells(sc,len/2+len%2+1);
if(sc->no_memory) { return sc->sink; }
typeflag(x) = (T_VECTOR | T_ATOM); typeflag(x) = (T_VECTOR | T_ATOM);
ivalue_unchecked(x)=len; ivalue_unchecked(x)=len;
set_num_integer(x); set_num_integer(x);
@ -3443,6 +3444,7 @@ static pointer opexe_2(scheme *sc, enum scheme_opcodes op) {
Error_1(sc,"vector: not a proper list:",sc->args); Error_1(sc,"vector: not a proper list:",sc->args);
} }
vec=mk_vector(sc,len); vec=mk_vector(sc,len);
if(sc->no_memory) { s_return(sc, sc->sink); }
for (x = sc->args, i = 0; is_pair(x); x = cdr(x), i++) { for (x = sc->args, i = 0; is_pair(x); x = cdr(x), i++) {
set_vector_elem(vec,i,car(x)); set_vector_elem(vec,i,car(x));
} }
@ -3460,6 +3462,7 @@ static pointer opexe_2(scheme *sc, enum scheme_opcodes op) {
fill=cadr(sc->args); fill=cadr(sc->args);
} }
vec=mk_vector(sc,len); vec=mk_vector(sc,len);
if(sc->no_memory) { s_return(sc, sc->sink); }
if(fill!=sc->NIL) { if(fill!=sc->NIL) {
fill_vector(vec,fill); fill_vector(vec,fill);
} }