[comp.lang.lisp.x] xscheme SAVE/RESTORE

raible@orville.nas.nasa.gov (Eric Raible) (02/15/90)

I've been running with the following fix to xscheme for SAVE/RESTORE
for several days now.  It works on my large workspace.

This result is really due to others: someone (I forgot) who posted a
fix to findvmemory to not garbage collect, and to my office mate
Jeffery Hultquist, who fixed a subtle bug involving vscurrent (which
tripped him up for other reasons).

My only contribution was to recognize that his fix allowed successful
SAVE/RESTORE.

- Eric Raible (raible@nas.nasa.gov)

The Original:

findvmemory(size)
  int size;
{
    VSEGMENT *vseg;
    
    /* first try garbage collecting */
    gc();

    /* look for a vector segment with enough space */
    for (vseg = vsegments; vseg != NULL; vseg = vseg->vs_next)
	if (vseg->vs_free + size < vseg->vs_top) {
	    if (vscurrent != NULL)
		vscurrent->vs_free = vfree;
	    vfree = vseg->vs_free;
	    vtop = vseg->vs_top;
	    vscurrent = vseg;
	    return;
	}
    
    /* allocate a new vector segment and make it current */
    vexpand(1);
}

============================================================================

THE FIX:

1) change getvspace (xsimage.c) to call makevmemory instead of findvmemory.

2) replace findvmemory (xsdmem.c) with the following code:

findvmemory(size)
  int size;
{
    gc();
    makevmemory(size);
}

/* makevmemory - make vector memory (used by 'xsimage.c') */
makevmemory(size)
  int size;
{
    VSEGMENT *vseg;
    
    if (vscurrent != NULL)
      vscurrent->vs_free = vfree;

    /* look for a vector segment with enough space */
    for (vseg = vsegments; vseg != NULL; vseg = vseg->vs_next)
	if (vseg->vs_free + size < vseg->vs_top) {
	    vfree = vseg->vs_free;
	    vtop = vseg->vs_top;
	    vscurrent = vseg;
	    return;
	}
    
    /* allocate a new vector segment and make it current */
    vexpand(1);
}