diff --git a/runtime/runtime.c b/runtime/runtime.c index c4ee5b2da..724d6cea2 100644 --- a/runtime/runtime.c +++ b/runtime/runtime.c @@ -498,7 +498,9 @@ extern void* Bstring (void*); void *Lclone (void *p) { data *res; int n; - +#ifdef DEBUG_PRINT + printf ("Lclone arg: %p %p\n", &p, p); fflush (stdout); +#endif __pre_gc (); if (UNBOXED(p)) return p; @@ -508,17 +510,26 @@ void *Lclone (void *p) { switch (t) { case STRING_TAG: +#ifdef DEBUG_PRINT + printf ("Lclone: string\n"); fflush (stdout); +#endif res = Bstring (a->contents); break; case ARRAY_TAG: case CLOSURE_TAG: +#ifdef DEBUG_PRINT + printf ("Lclone: closure or array\n"); fflush (stdout); +#endif res = (data*) alloc (sizeof(int) * (l+1)); memcpy (res, a, sizeof(int) * (l+1)); res = res->contents; break; case SEXP_TAG: +#ifdef DEBUG_PRINT + printf ("Lclone: sexp\n"); fflush (stdout); +#endif res = (sexp*) alloc (sizeof(int) * (l+2)); memcpy (res, TO_SEXP(p), sizeof(int) * (l+2)); res = res->contents; @@ -528,10 +539,15 @@ void *Lclone (void *p) { default: failure ("invalid tag %d in clone *****\n", t); } - } + } +#ifdef DEBUG_PRINT + printf ("Lclone ends1\n"); fflush (stdout); +#endif __post_gc (); - +#ifdef DEBUG_PRINT + printf ("Lclone ends2\n"); fflush (stdout); +#endif return res; } @@ -706,15 +722,25 @@ extern void* LmakeString (int length) { extern void* Bstring (void *p) { int n = strlen (p); - data *s; + data *s = NULL; __pre_gc (); - +#ifdef DEBUG_PRINT + printf ("Bstring: call LmakeString %p %p %i\n", p, s, n); fflush(stdout); +#endif + SET_EXTRA_ROOT (&p); s = LmakeString (BOX(n)); +#ifdef DEBUG_PRINT + printf ("Bstring: call strncpy: %p %p %i\n", p, s, n); fflush(stdout); +#endif strncpy (s, p, n + 1); +#ifdef DEBUG_PRINT + printf ("Bstring: ends\n"); fflush(stdout); +#endif __post_gc (); + CLEAR_EXTRA_ROOT; return s; } @@ -1164,20 +1190,21 @@ extern int Lwrite (int n) { extern void set_args (int argc, char *argv[]) { data *a; - int n = argc; + int n = argc, *p = NULL; int i; __pre_gc (); - SET_EXTRA_ROOT (LmakeArray (BOX(n))); + p = LmakeArray (BOX(n)); + SET_EXTRA_ROOT (&p); for (i=0; i