pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:28:   /** The empty array. */   PMOD_EXPORT struct array empty_array=   {    PIKE_CONSTANT_MEMOBJ_INIT(1, PIKE_T_ARRAY), /* Never free */    0, /* Size = 0 */    0, /* malloced Size = 0 */    0, /* no types */    0, /* no flags */    &weak_empty_array, /* Next */    0, /* previous */ -  empty_array.real_item, /* Initialize the item pointer. */ -  {SVALUE_INIT_FREE}, +  empty_array.u.real_item, /* Initialize the item pointer. */ +  {{SVALUE_INIT_FREE}},   };      /** The empty weak array. */   PMOD_EXPORT struct array weak_empty_array=   {    PIKE_CONSTANT_MEMOBJ_INIT(1, PIKE_T_ARRAY), /* Never free */    0, /* Size = 0 */    0, /* malloced Size = 0 */    0, /* no types */    ARRAY_WEAK_FLAG, /* weak */    0, /* next */    &empty_array, /* previous */ -  weak_empty_array.real_item, /* Initialize the item pointer. */ -  {SVALUE_INIT_FREE}, +  weak_empty_array.u.real_item, /* Initialize the item pointer. */ +  {{SVALUE_INIT_FREE}},   };      struct array *first_array = &empty_array;   struct array *gc_internal_array = 0;   static struct array *gc_mark_array_pos;      #ifdef TRACE_UNFINISHED_TYPE_FIELDS   PMOD_EXPORT int accept_unfinished_type_fields = 0;   PMOD_EXPORT void dont_accept_unfinished_type_fields (void *orig)   {
pike.git/src/array.c:107:       v=xcalloc(length, 1);       GC_ALLOC(v);    gc_init_marker(v);       /* for now, we don't know what will go in here */    v->type_field = BIT_MIXED | BIT_UNFINISHED;       v->malloced_size = (INT32)(size + extra_space); -  v->item=v->real_item; +  v->item=v->u.real_item;    v->size = (INT32)size;    INIT_PIKE_MEMOBJ(v, T_ARRAY);    DOUBLELINK (first_array, v);       return v;   TOO_BIG:    Pike_error("Too large array (size %ld is too big).\n", length);   }      /**
pike.git/src/array.c:389:   PMOD_EXPORT struct array *array_insert(struct array *v,struct svalue *s,INT32 index)   {   #ifdef PIKE_DEBUG    if(index<0 || index>v->size)    Pike_fatal("Illegal index in low level insert routine.\n");   #endif       /* Can we fit it into the existing block? */    if(v->refs<=1 && (v->malloced_size > v->size))    { -  if ((v->item != v->real_item) && +  if ((v->item != v->u.real_item) &&    (((index<<1) < v->size) || -  ((v->item + v->size) == (v->real_item + v->malloced_size)))) { +  ((v->item + v->size) == (v->u.real_item + v->malloced_size)))) {    memmove(ITEM(v)-1, ITEM(v), index * sizeof(struct svalue));    v->item--;    } else {    memmove(ITEM(v)+index+1, ITEM(v)+index,    (v->size-index) * sizeof(struct svalue));    }    assert_free_svalue (ITEM(v) + index);    v->size++;    }else{    struct array *ret;
pike.git/src/array.c:466:    lvalue already has the array as it's value.    */    if( (v->refs == 2) && (lval_type != PIKE_T_GET_SET) ) {    if ((TYPEOF(*lval) == T_OBJECT) &&    lval->u.object->prog &&    ((FIND_LFUN(lval->u.object->prog, LFUN_ASSIGN_INDEX) >= 0) ||    (FIND_LFUN(lval->u.object->prog, LFUN_ASSIGN_ARROW) >= 0))) {    /* There's a function controlling assignments in this object,    * so we can't alter the array in place.    */ -  } else if( v->real_item+v->malloced_size >= v->item+v->size+args ) { +  } else if( v->u.real_item+v->malloced_size >= v->item+v->size+args ) {    struct svalue *from = val+1;    int i;    for( i = 0; i<args; i++,from++ )    {    v->item[v->size++] = *from;    v->type_field |= 1<<TYPEOF(*from);    }    Pike_sp -= args;    stack_pop_2_elems_keep_top();    return;
pike.git/src/array.c:600:       /* Ensure that one of the empty arrays are returned if size is zero. */    if (!size && a->malloced_size) return array_shrink (a, size);       if(a->size == size) return a;    if(size > a->size)    {    /* We should grow the array */       if((a->malloced_size >= size) && -  ((a->item + size) <= (a->real_item + a->malloced_size))) +  ((a->item + size) <= (a->u.real_item + a->malloced_size)))    {    for(;a->size < size; a->size++)    {    SET_SVAL(ITEM(a)[a->size], T_INT, NUMBER_NUMBER, integer, 0);    }    a->type_field |= BIT_INT;    return a;    } else {    struct array *ret;    ret = array_set_flags(low_allocate_array(size, size + 1), a->flags);
pike.git/src/array.c:1665: Inside #if 1
   {    INT32 tmp=0; /* Svalues needed so far. */    INT32 tmp2 = 0;    INT32 e2 = -1;       for(e=0;e<args;e++)    {    v=argp[e].u.array;    if(v->refs == 1 && v->malloced_size >= size)    { -  if (((v->item - v->real_item) >= tmp) && -  ((v->item + size - tmp) <= (v->real_item + v->malloced_size))) { +  if (((v->item - v->u.real_item) >= tmp) && +  ((v->item + size - tmp) <= (v->u.real_item + v->malloced_size))) {    /* There's enough space before and after. */    debug_malloc_touch(v);    mark_free_svalue(argp + e);    for(tmp=e-1;tmp>=0;tmp--)    {    v2 = argp[tmp].u.array;    debug_malloc_touch(v2);    v->type_field |= v2->type_field;    assign_svalues_no_free(ITEM(v) - v2->size, ITEM(v2),    v2->size, v2->type_field);
pike.git/src/array.c:1712: Inside #if 1
   tmp2 = tmp;    v2 = v;    e2 = e;    }    }    tmp+=v->size;    }    if (v2) {    debug_malloc_touch(v2);    mark_free_svalue(argp + e2); -  memmove(v2->real_item + tmp2, ITEM(v2), +  memmove(v2->u.real_item + tmp2, ITEM(v2),    v2->size * sizeof(struct svalue)); -  v2->item = v2->real_item + tmp2; +  v2->item = v2->u.real_item + tmp2;    for(tmp=e2-1;tmp>=0;tmp--)    {    v = argp[tmp].u.array;    debug_malloc_touch(v);    v2->type_field |= v->type_field;    assign_svalues_no_free(ITEM(v2) - v->size, ITEM(v),    v->size, v->type_field);    v2->item -= v->size;    v2->size += v->size;    }
pike.git/src/array.c:2719: Inside #if defined(PIKE_DEBUG)
      if(a->size > a->malloced_size)    Pike_fatal("Array is larger than malloced block!\n");       if(a->size < 0)    Pike_fatal("Array size is negative!\n");       if(a->malloced_size < 0)    Pike_fatal("Array malloced size is negative!\n");    -  if((a->item + a->size) > (a->real_item + a->malloced_size)) +  if((a->item + a->size) > (a->u.real_item + a->malloced_size))    Pike_fatal("Array uses memory outside of the malloced block!\n");    -  if(a->item < a->real_item) +  if(a->item < a->u.real_item)    {   #ifdef DEBUG_MALLOC    describe(a);   #endif    Pike_fatal("Array item pointer is too small!\n");    }       if(a->refs <=0 )    Pike_fatal("Array has zero refs.\n");