pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: array.c,v 1.140 2004/09/16 14:57:23 grubba Exp $ + || $Id: array.c,v 1.141 2004/09/16 15:25:34 grubba Exp $   */      #include "global.h"   #include "svalue.h"   #include "array.h"   #include "object.h"   #include "las.h"   #include "stralloc.h"   #include "interpret.h"   #include "opcodes.h"
pike.git/src/array.c:20:   #include "pike_memory.h"   #include "gc.h"   #include "main.h"   #include "security.h"   #include "stuff.h"   #include "bignum.h"   #include "cyclic.h"   #include "multiset.h"   #include "mapping.h"    - RCSID("$Id: array.c,v 1.140 2004/09/16 14:57:23 grubba Exp $"); + RCSID("$Id: array.c,v 1.141 2004/09/16 15:25:34 grubba Exp $");      PMOD_EXPORT struct array empty_array=   {    PIKE_CONSTANT_MEMOBJ_INIT(1), /* Never free */    &weak_empty_array, /* Next */    &weak_shrink_empty_array, /* previous (circular) */    0, /* Size = 0 */    0, /* malloced Size = 0 */    0, /* no types */    0, /* no flags */
pike.git/src/array.c:156:   }      PMOD_EXPORT void do_free_array(struct array *a)   {    if (a)    free_array(a);   }      PMOD_EXPORT struct array *array_set_flags(struct array *a, int flags)   { +  flags = (flags & ~ARRAY_CONSIDER_REALLOC) | +  (a->flags & ARRAY_CONSIDER_REALLOC); +     if (a->size)    a->flags = flags;    else {    free_array(a);    switch (flags) {    case 0:    add_ref(a = &empty_array); break;    case ARRAY_WEAK_FLAG:    add_ref(a = &weak_empty_array); break;    case ARRAY_WEAK_FLAG|ARRAY_WEAK_SHRINK:
pike.git/src/array.c:1955:    {    ret=(struct array *)p->pointer_b;    add_ref(ret);    return ret;    }    }       ret=allocate_array_no_init(a->size,0);    doing.pointer_b=(void *)ret;    -  ret->flags = a->flags & ~ARRAY_LVALUE; +  ret->flags = a->flags & ~(ARRAY_LVALUE|ARRAY_CONSIDER_REALLOC);       copy_svalues_recursively_no_free(ITEM(ret),ITEM(a),a->size,&doing);       ret->type_field=a->type_field;    return ret;   }      PMOD_EXPORT void apply_array(struct array *a, INT32 args)   {    INT32 e;
pike.git/src/array.c:2142: Inside #if defined(PIKE_DEBUG)
   if (a->refs != 1)    Pike_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 (!debug_gc_mark_weak_svalues(a->item+e, 1, T_ARRAY, a)) {    a->item[d++]=a->item[e];    t |= 1 << a->item[e].type;    } +  if (d != a->size) {    a->size=d; -  +  a->flags |= ARRAY_CONSIDER_REALLOC;    } -  +  }    else    if (!(t = debug_gc_mark_weak_svalues(a->item, a->size, T_ARRAY, a)))    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;