pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:16:   #include "pike_types.h"   #include "fsort.h"   #include "builtin_functions.h"   #include "pike_memory.h"   #include "gc.h"   #include "main.h"   #include "security.h"   #include "stuff.h"   #include "bignum.h"    - RCSID("$Id: array.c,v 1.88 2000/09/17 19:53:52 grubba Exp $"); + RCSID("$Id: array.c,v 1.89 2000/09/30 15:58:30 mast Exp $");      PMOD_EXPORT struct array empty_array=   {    1, /* Never free */   #ifdef PIKE_SECURITY    0,   #endif    &empty_array, /* Next */    &empty_array, /* previous (circular) */    0, /* Size = 0 */
pike.git/src/array.c:1786: Inside #if defined(PIKE_DEBUG)
   fatal("Null pointer in array list.\n");    } while (a != & empty_array);   }   #endif /* PIKE_DEBUG */         static void gc_check_array(struct array *a)   {    if(a->type_field & BIT_COMPLEX)    { -  if (a->flags & ARRAY_WEAK_FLAG) +  if (a->flags & ARRAY_WEAK_FLAG) {    debug_gc_check_weak_svalues(ITEM(a), a->size, T_ARRAY, a); -  +  gc_checked_as_weak(a); +  }    else    debug_gc_check_svalues(ITEM(a), a->size, T_ARRAY, a);    }   }      static void gc_recurse_weak_array(struct array *a,    TYPE_FIELD (*recurse_fn)(struct svalue *, size_t))   {    int e;    TYPE_FIELD t;
pike.git/src/array.c:1852:    gc_mark_array_pos = a->next;    if (a == gc_internal_array)    gc_internal_array = a->next;    else {    UNLINK_ARRAY(a);    LINK_ARRAY(a); /* Linked in first. */    }       if (a->type_field & BIT_COMPLEX)    { -  if (a->flags & ARRAY_WEAK_FLAG) -  gc_recurse_weak_array(a, gc_mark_weak_svalues); +  if (a->flags & ARRAY_WEAK_FLAG) { +  int e; +  TYPE_FIELD t; +  +  if(a->flags & ARRAY_WEAK_SHRINK) { +  int d=0; + #ifdef PIKE_DEBUG +  if (a->refs != 1) +  fatal("Got %d refs to weak shrink array " +  "which we'd like to change the size on.\n", a->refs); + #endif +  t = 0; +  for(e=0;e<a->size;e++) +  if (!gc_mark_weak_svalues(a->item+e, 1)) { +  a->item[d++]=a->item[e]; +  t |= 1 << a->item[e].type; +  } +  a->size=d; +  } +  else +  if (!(t = gc_mark_weak_svalues(a->item, a->size))) +  t = a->type_field; +  +  /* Ugly, but we are not allowed to change type_field +  * at the same time as the array is being built... +  * Actually we just need better primitives for building arrays. +  */ +  if(!(a->type_field & BIT_UNFINISHED) || a->refs!=1) +  a->type_field = t; +  else +  a->type_field |= t; +  +  gc_assert_checked_as_weak(a); +  }    else {    TYPE_FIELD t;    if ((t = gc_mark_svalues(ITEM(a), a->size))) {    if(!(a->type_field & BIT_UNFINISHED) || a->refs!=1)    a->type_field = t;    else    a->type_field |= t;    } -  +  gc_assert_checked_as_nonweak(a);    }    }    }   }      void real_gc_cycle_check_array(struct array *a, int weak)   {    GC_CYCLE_ENTER(a, weak) {    int e;   #ifdef PIKE_DEBUG    if (a == &empty_array) fatal("Trying to gc cycle check empty_array.\n");   #endif       if (a->type_field & BIT_COMPLEX)    { -  if (a->flags & ARRAY_WEAK_FLAG) -  gc_recurse_weak_array(a, gc_cycle_check_weak_svalues); +  if (a->flags & ARRAY_WEAK_FLAG) { +  if (gc_cycle_check_weak_svalues(ITEM(a), a->size)) { + #ifdef PIKE_DEBUG +  fatal("Didn't expect an svalue zapping now.\n"); + #endif +  } +  gc_assert_checked_as_weak(a); +  }    else {    TYPE_FIELD t;    if ((t = gc_cycle_check_svalues(ITEM(a), a->size))) {    if(!(a->type_field & BIT_UNFINISHED) || a->refs!=1)    a->type_field = t;    else    a->type_field |= t;    } -  +  gc_assert_checked_as_nonweak(a);    }    }    } GC_CYCLE_LEAVE;   }      #ifdef PIKE_DEBUG   unsigned gc_touch_all_arrays(void)   {    unsigned n = 0;    struct array *a = &empty_array;
pike.git/src/array.c:2001: Inside #if defined(PIKE_DEBUG)
   if(t & (1<<e))    fprintf(stderr," %s",get_name_of_type(e));       for(;e<16;e++)    if(t & (1<<e))    fprintf(stderr," <%d>",e);   }      void debug_dump_array(struct array *a)   { -  fprintf(stderr,"Location=%p Refs=%d, next=%p, prev=%p, size=%d, malloced_size=%d\n", +  fprintf(stderr,"Location=%p Refs=%d, next=%p, prev=%p, " +  "flags=0x%x, size=%d, malloced_size=%d%s\n",    a,    a->refs,    a->next,    a->prev, -  +  a->flags,    a->size, -  a->malloced_size); +  a->malloced_size, +  a == &empty_array ? " (the empty_array)" : "");    fprintf(stderr,"Type field = ");    debug_dump_type_field(a->type_field);    fprintf(stderr,"\n");    simple_describe_array(a);   }   #endif         void zap_all_arrays(void)   {