pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:85:    add_ref(&empty_array);    return &empty_array;    }       /* Limits size to (1<<29)-4 */    if( (size_t)(size+extra_space-1) >    (LONG_MAX-sizeof(struct array))/sizeof(struct svalue) )    Pike_error("Too large array (size %ld exceeds %ld).\n",    (long)(size+extra_space-1),    (long)((LONG_MAX-sizeof(struct array))/sizeof(struct svalue)) ); -  v=(struct array *)malloc(sizeof(struct array)+ +  v=malloc(sizeof(struct array)+    (size+extra_space-1)*sizeof(struct svalue));    if(!v)    Pike_error(msg_out_of_mem_2, sizeof(struct array)+    (size+extra_space-1)*sizeof(struct svalue));       GC_ALLOC(v);          if (size+extra_space)    /* for now, we don't know what will go in here */
pike.git/src/array.c:870:      /* The sort is stable. */   INT32 *get_order(struct array *v, cmpfun fun)   {    INT32 e, *current_order;    ONERROR tmp;       if(!v->size) return 0;       /* Overlow safe: ((1<<29)-4)*4 < ULONG_MAX */ -  current_order=(INT32 *)xalloc(v->size * sizeof(INT32)); +  current_order=xalloc(v->size * sizeof(INT32));    SET_ONERROR(tmp, free, current_order);    for(e=0; e<v->size; e++) current_order[e]=e;       get_order_fsort(current_order,    current_order+v->size-1,    fun,    ITEM(v));       UNSET_ONERROR(tmp);    return current_order;
pike.git/src/array.c:1271:    * get_alpha_order. */   PMOD_EXPORT INT32 *stable_sort_array_destructively(struct array *v)   {    INT32 *current_order;    ONERROR tmp;    int e;       if(!v->size) return NULL;       /* Overflow safe: ((1<<29)-4)*4 < ULONG_MAX */ -  current_order=(INT32 *)xalloc(v->size * sizeof(INT32)); +  current_order=xalloc(v->size * sizeof(INT32));    SET_ONERROR(tmp, free, current_order);    for(e=0; e<v->size; e++) current_order[e]=e;       low_stable_sort_svalues (0, v->size - 1, ITEM (v), current_order, v->size);       UNSET_ONERROR (tmp);    return current_order;   }      
pike.git/src/array.c:1538:    }   #endif    if(!(a->type_field & b->type_field) &&    !((a->type_field | b->type_field) & BIT_OBJECT))    {    /* do smart optimizations */    switch(opcode)    {    case PIKE_ARRAY_OP_AND:    /* Trivially overflow safe */ -  ret=(INT32 *)xalloc(sizeof(INT32)); +  ret=xalloc(sizeof(INT32));    *ret=0;    return ret;       case PIKE_ARRAY_OP_SUB:    /* Overlow safe: ((1<<29)-4+1)*4 < ULONG_MAX */ -  ptr=ret=(INT32 *)xalloc(sizeof(INT32)*(a->size+1)); +  ptr=ret=xalloc(sizeof(INT32)*(a->size+1));    *(ptr++)=a->size;    for(i=0;i<a->size;i++) *(ptr++)=i;    return ret;    }    }       /* Note: The following is integer overflow safe as long as    * sizeof(struct svalue) >= 2*sizeof(INT32).    */ -  ptr=ret=(INT32 *)xalloc(sizeof(INT32)*(a->size + b->size + 1)); +  ptr=ret=xalloc(sizeof(INT32)*(a->size + b->size + 1));    SET_ONERROR(r, free,ret);    ptr++;       while(ap < a->size && bp < b->size)    {    i=set_svalue_cmpfun(ITEM(a)+ap,ITEM(b)+bp);    if(i < 0)    i=opcode >> 8;    else if(i > 0)    i=opcode;
pike.git/src/array.c:1916:   #endif       SET_ONERROR(r1,do_free_array,a);    SET_ONERROR(r2,do_free_array,b);       if(a->refs==1 || !a->size)    {    arra=ITEM(a);    }else{    /* Overlow safe: ((1<<29)-4)*8 < ULONG_MAX */ -  arra=(struct svalue *)xalloc(a->size*sizeof(struct svalue)); +  arra=xalloc(a->size*sizeof(struct svalue));    MEMCPY(arra,ITEM(a),a->size*sizeof(struct svalue));    SET_ONERROR(r3,free,arra);    }       if(b->refs==1 || !b->size)    {    arrb=ITEM(b);    }else{    /* Overlow safe: ((1<<29)-4)*8 < ULONG_MAX */ -  arrb=(struct svalue *)xalloc(b->size*sizeof(struct svalue)); +  arrb=xalloc(b->size*sizeof(struct svalue));    MEMCPY(arrb,ITEM(b),b->size*sizeof(struct svalue));    SET_ONERROR(r4,free,arrb);    }       set_sort_svalues(arra,arra+a->size-1);    set_sort_svalues(arrb,arrb+b->size-1);       ret=low_allocate_array(0,32);    SET_ONERROR(r5,do_free_array,ret);    ap=bp=0;