[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Save-application with foreign functions included?



At 15:34 2/18/93 +0000, Tim Perkis wrote:
>I'm having trouble getting my application, which includes several C
>modules and libraries, embedded in a "save-application" image. I could load
>the external code at startup, but I was hoping to avoid the time delay
>(ff-load is slow!). Is there a trick I'm missing about saving  an
>application image in this case?

No trick that I know of. SAVE-APPLICATION saves the A5 worlds created
by FF-LOAD and restores them on restart. This works correctly for the
"ccl:examples;ff-examples;*" files distributed with MCL 2.0. One
thing I can think of that may be causing you problems is if your C
code has global variables that you are neglecting to initialize
properly at startup. If these globals are part of a library to which
you don't have source, it may be difficult for you to do anything about
it.

For example, when MCL loads the following code from an image created
after maybe_initialize was called, "initialized" will be non-zero, so
no initialization will happen, and "block" will end up pointing at
a random memory address. (my apologies for errors in C syntax. I very
rarely write C code).

------------------------------------------------------------------------

static short initialized=0;
static Ptr block;

maybe_initialize ()
  {
    if (!initialized) {
      block = NewPtr(1000);
      initialized=1;
    }
  }