pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:176:   }      /**    * Free all elements in an array and set them to zero.    */   PMOD_EXPORT void clear_array(struct array *a)   {    if (!a->size) return;    free_svalues(ITEM(a), a->size, a->type_field);    /* NB: We know that INT_T == 0. */ -  MEMSET(ITEM(a), 0, a->size * sizeof(struct svalue)); +  memset(ITEM(a), 0, a->size * sizeof(struct svalue));    a->type_field = BIT_INT;   }      /**    * Set the flags on an array. If the array is empty then only the    * weak flag is significant.    */   PMOD_EXPORT struct array *array_set_flags(struct array *a, int flags)   {    if (a->size)
pike.git/src/array.c:392: Inside #if defined(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) &&    (((index<<1) < v->size) ||    ((v->item + v->size) == (v->real_item + v->malloced_size)))) { -  MEMMOVE((char *)(ITEM(v)-1), -  (char *)(ITEM(v)), -  index * sizeof(struct svalue)); +  memmove(ITEM(v)-1, ITEM(v), index * sizeof(struct svalue));    v->item--;    } else { -  MEMMOVE((char *)(ITEM(v)+index+1), -  (char *)(ITEM(v)+index), +  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;       ret = array_set_flags(allocate_array_no_init(v->size+1, v->size + 1),    v->flags);    ret->type_field = v->type_field;    -  MEMCPY(ITEM(ret), ITEM(v), sizeof(struct svalue) * index); -  MEMCPY(ITEM(ret)+index+1, ITEM(v)+index, +  memcpy(ITEM(ret), ITEM(v), sizeof(struct svalue) * index); +  memcpy(ITEM(ret)+index+1, ITEM(v)+index,    sizeof(struct svalue) * (v->size-index));    assert_free_svalue (ITEM(ret) + index);    if (v->refs == 1) {    /* Optimization: Steal the references. */    v->size = 0;    } else if (v->type_field & BIT_REF_TYPES) {    /* Adjust the references. */    int e = v->size;    struct svalue *s = ITEM(ret);    while (e--) {
pike.git/src/array.c:549:    free_svalues(ITEM(v) + size, v->size - size, v->type_field);    v->size=size;       if(size*4 < v->malloced_size + 4) /* Should we realloc it? */    {    a = array_set_flags(allocate_array_no_init(size, 0), v->flags);    if (a->size) {    a->type_field = v->type_field;    }    -  MEMCPY(ITEM(a), ITEM(v), size*sizeof(struct svalue)); +  memcpy(ITEM(a), ITEM(v), size*sizeof(struct svalue));    v->size=0;    free_array(v);    return a;    }else{    return v;    }   }      /**    * Resize an array destructively, with the exception that a may be one
pike.git/src/array.c:588:    {    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); -  MEMCPY(ITEM(ret), ITEM(a), sizeof(struct svalue)*a->size); +  memcpy(ITEM(ret), ITEM(a), sizeof(struct svalue)*a->size);    ret->type_field = DO_NOT_WARN((TYPE_FIELD)(a->type_field | BIT_INT));    a->size=0;    free_array(a);    return ret;    }    } else {    return array_shrink(a, size);    }   }   
pike.git/src/array.c:631:    /* NOTE: The following uses the fact that array_set_flags()    * will reallocate the array if it has zero size!    */    return array_set_flags(v, v->flags);    } else if(v->size*4 + 4 < v->malloced_size ) /* Should we realloc it? */    {    a = array_set_flags(allocate_array_no_init(v->size-1, 0), v->flags);    a->type_field = v->type_field;       if(index>0) -  MEMCPY(ITEM(a), ITEM(v), index*sizeof(struct svalue)); +  memcpy(ITEM(a), ITEM(v), index*sizeof(struct svalue));    if(v->size-index>1) -  MEMCPY(ITEM(a)+index, +  memcpy(ITEM(a)+index,    ITEM(v)+index+1,    (v->size-index-1)*sizeof(struct svalue));    v->size=0;    free_array(v);    return a;    } else {    if(v->size-index>1)    { -  MEMMOVE((char *)(ITEM(v)+index), -  (char *)(ITEM(v)+index+1), +  memmove(ITEM(v)+index, ITEM(v)+index+1,    (v->size-index-1)*sizeof(struct svalue));    }    v->size--;    return v;    }   }      static ptrdiff_t fast_array_search( struct array *v, struct svalue *s, ptrdiff_t start )   {    ptrdiff_t e;
pike.git/src/array.c:1680: Inside #if 1 and #if defined(PIKE_DEBUG)
   }   #ifdef PIKE_DEBUG    if(d_flag>1)    check_array(v);   #endif    return v;    }    if (!v2 || (v->size > v2->size)) {    /* Got a potential candidate.    * -  * Optimize for maximum MEMMOVE() +  * Optimize for maximum memmove()    * (ie minimum assign_svalues_no_free()).    */    tmp2 = tmp;    v2 = v;    e2 = e;    }    }    tmp+=v->size;    }    if (v2) {    debug_malloc_touch(v2);    mark_free_svalue(argp + e2); -  MEMMOVE((char *)(v2->real_item + tmp2), (char *)ITEM(v2), +  memmove(v2->real_item + tmp2, ITEM(v2),    v2->size * sizeof(struct svalue));    v2->item = v2->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;
pike.git/src/array.c:2151:   }      /** Push elements of an array onto the stack. The array will be freed.    */   PMOD_EXPORT void push_array_items(struct array *a)   {    check_stack(a->size);    check_array_for_destruct(a);    if(a->refs == 1)    { -  MEMCPY(Pike_sp,ITEM(a),sizeof(struct svalue)*a->size); +  memcpy(Pike_sp,ITEM(a),sizeof(struct svalue)*a->size);    Pike_sp += a->size;    a->size=0;    free_array(a);    }else{    assign_svalues_no_free(Pike_sp, ITEM(a), a->size, a->type_field);    Pike_sp += a->size;    free_array(a);    }   }   
pike.git/src/array.c:2248:    * Pops a number of arguments off of the stack an puts them in an array.    * The 'top' of the stack will be the last element in the array.    * @param args The number of arguments to aggregate.    */   PMOD_EXPORT struct array *aggregate_array(INT32 args)   {    struct array *a;       a=allocate_array_no_init(args,0);    if (args) { -  MEMCPY((char *)ITEM(a),(char *)(Pike_sp-args),args*sizeof(struct svalue)); +  memcpy(ITEM(a),Pike_sp-args,args*sizeof(struct svalue));    array_fix_type_field (a);    Pike_sp-=args;    DO_IF_DMALLOC(while(args--) dmalloc_touch_svalue(Pike_sp + args));    }    return a;   }      /** Add an element to the end of an array by resizing the array.    *    * @param a the array to be appended