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.106 2001/06/06 02:22:38 mast Exp $"); + RCSID("$Id: array.c,v 1.107 2001/06/07 08:26:46 hubbe 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:72:    Pike_error("Couldn't allocate array, out of memory.\n");       GC_ALLOC(v);          /* for now, we don't know what will go in here */    v->type_field=BIT_MIXED | BIT_UNFINISHED;    v->flags=0;       v->malloced_size = DO_NOT_WARN((INT32)(size + extra_space)); +  v->item=v->real_item;    v->size = DO_NOT_WARN((INT32)size);    INIT_PIKE_MEMOBJ(v);    LINK_ARRAY(v);       for(e=0;e<v->size;e++)    {    ITEM(v)[e].type=T_INT;    ITEM(v)[e].subtype=NUMBER_NUMBER;    ITEM(v)[e].u.integer=0;    }
pike.git/src/array.c:508:   {    struct array *a;      #ifdef PIKE_DEBUG    if(start > end || end>v->size || start<0)    fatal("Illegal arguments to slice_array()\n");       if(d_flag > 1) array_check_type_field(v);   #endif    -  if(start==0 && v->refs==1) /* Can we use the same array? */ + #if 1 +  if(v->refs==1) /* Can we use the same array? */    { -  +  if((end-start) && +  (end-start)*2 > v->malloced_size +4 ) /* don't waste too much memory */ +  {    add_ref(v); -  return array_shrink(v,end); +  free_svalues(ITEM(v) + end, v->size - end, v->type_field); +  free_svalues(ITEM(v), start, v->type_field); +  v->item+=start; +  v->malloced_size+=start; +  v->size=end-start; +  return v;    } -  +  } + #endif       a=allocate_array_no_init(end-start,0);    a->type_field = v->type_field;       assign_svalues_no_free(ITEM(a), ITEM(v)+start, end-start, v->type_field);       return a;   }      /*