pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:2046:    struct svalue *ip=ITEM(a), *dp=ip;    int destructive = 1;       if( size == 0 )    return copy_array(a);       if( a->refs > 1 )    {    /* We only need to do anything if the value exists in the array. */    ssize_t off = fast_array_search( a, b, 0 ); +  TYPE_FIELD tmp;       if( off == -1 )    /* We still need to return a new array. */    return copy_array(a);       /* In this case we generate a new array and modify that one. */    destructive = 0;    from = (size_t)off; -  +  tmp = a->type_field;    a = allocate_array_no_init(size-1,0); -  +  a->type_field = tmp;    SET_ONERROR( ouch, do_free_array, a );    dp = ITEM(a);       /* Copy the part of the array that is not modified first.. */    for( to=0; to<from; to++, ip++, dp++)    {    assign_svalue_no_free(dp, ip);    type_field |= 1<<TYPEOF(*dp);    }    a->size = from;
pike.git/src/array.c:2101:    for( ;from<size; from++, ip++ )    MATCH_COPY( !UNSAFE_IS_ZERO(ip) );    }    else if((a->type_field & to_type) || ((a->type_field | to_type) & BIT_OBJECT))    {    for( ; from<size; from++, ip++ )    MATCH_COPY( !is_eq(ip,b) );    }    else /* b does not exist in the array. */    { -  a->refs++; +  add_ref(a);    return a;    }   #undef MATCH_COPY       if( dp != ip )    {    a->type_field = type_field;    a->size = dp-ITEM(a);    }       if( !destructive )    UNSET_ONERROR( ouch );    else -  a->refs++; +  add_ref(a);    -  +  if( a->size )    return a; -  +  +  free_array(a); +  add_ref(&empty_array); +  return &empty_array;   }      /** Subtract an array from another.   */   PMOD_EXPORT struct array *subtract_arrays(struct array *a, struct array *b)   {   #ifdef PIKE_DEBUG    if(d_flag > 1)    {    array_check_type_field(b);