Branch: Tag:

2001-12-16

2001-12-16 18:49:20 by Martin Stjernholm <mast@lysator.liu.se>

Fixes to make describe_svalue safe to use while inside the gc (i.e. no
_sprintf callbacks and no temporary allocations of arrays, strings and
stuff).

Rev: src/mapping.c:1.145
Rev: src/svalue.c:1.131

5:   \*/   /**/   #include "global.h" - RCSID("$Id: mapping.c,v 1.144 2001/12/01 23:50:04 mast Exp $"); + RCSID("$Id: mapping.c,v 1.145 2001/12/16 18:49:20 mast Exp $");   #include "main.h"   #include "object.h"   #include "mapping.h"
1658:    }    }    +  if (Pike_in_gc) { +  /* Have to do without any temporary allocations. */ +  struct keypair *k; +  int notfirst = 0; +  +  if (m->data->size == 1) { +  my_strcat("([ /* 1 element */\n"); +  } else { +  sprintf(buf, "([ /* %ld elements */\n", (long)m->data->size); +  my_strcat(buf); +  } +  +  /* no mapping locking required (I hope) */ +  NEW_MAPPING_LOOP(m->data) { +  struct svalue *tmp; +  if (notfirst) my_strcat(",\n"); +  else notfirst = 1; +  for(d = 0; d < indent; d++) +  my_putchar(' '); +  describe_svalue(&k->ind, indent+2, &doing); +  my_putchar(':'); +  describe_svalue(&k->val, indent+2, &doing); +  } +  +  my_putchar('\n'); +  for(e=2; e<indent; e++) my_putchar(' '); +  my_strcat("])"); +  return; +  } +     a = mapping_indices(m);    SET_ONERROR(err, do_free_array, a);