pike.git / src / array.c

version» Context lines:

pike.git/src/array.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: array.c,v 1.163 2005/02/14 15:54:59 mast Exp $ + || $Id: array.c,v 1.164 2005/05/18 12:36:53 mast Exp $   */      #include "global.h"   #include "svalue.h"   #include "array.h"   #include "object.h"   #include "las.h"   #include "stralloc.h"   #include "interpret.h"   #include "opcodes.h"
pike.git/src/array.c:20:   #include "pike_memory.h"   #include "gc.h"   #include "main.h"   #include "pike_security.h"   #include "stuff.h"   #include "bignum.h"   #include "cyclic.h"   #include "multiset.h"   #include "mapping.h"    - RCSID("$Id: array.c,v 1.163 2005/02/14 15:54:59 mast Exp $"); + RCSID("$Id: array.c,v 1.164 2005/05/18 12:36:53 mast Exp $");      PMOD_EXPORT struct array empty_array=   {    PIKE_CONSTANT_MEMOBJ_INIT(1), /* Never free */    &weak_empty_array, /* Next */    0, /* previous */    0, /* Size = 0 */    0, /* malloced Size = 0 */    0, /* no types */    0, /* no flags */
pike.git/src/array.c:84:   {    struct array *v;    ptrdiff_t e;       if(size+extra_space == 0)    {    add_ref(&empty_array);    return &empty_array;    }    -  if( (size+extra_space-1) > +  if( (size_t) (size+extra_space-1) >    (ULONG_MAX-sizeof(struct array))/sizeof(struct svalue) )    Pike_error("Too large array (memory size exceeds size of size_t)\n");    v=(struct array *)malloc(sizeof(struct array)+    (size+extra_space-1)*sizeof(struct svalue));    if(!v)    Pike_error(msg_out_of_mem);       GC_ALLOC(v);      
pike.git/src/array.c:263:    case T_INT: {    INT_TYPE p = ind->u.integer;    INT_TYPE i = p < 0 ? p + a->size : p;    if(i<0 || i>=a->size) {    struct svalue tmp;    tmp.type=T_ARRAY;    tmp.u.array=a;    if (a->size) {    index_error(0,0,0,&tmp,ind,    "Index %"PRINTPIKEINT"d is out of array range " -  "%"PRINTPTRDIFFT"d..%"PRINTPTRDIFFT"d.\n", -  p, -a->size, a->size-1); +  "%d..%d.\n", p, -a->size, a->size-1);    } else {    index_error(0,0,0,&tmp,ind,    "Attempt to index the empty array with %"PRINTPIKEINT"d.\n", p);    }    }    array_index_no_free(s,a,i);    break;    }       case T_STRING:
pike.git/src/array.c:316:      PMOD_EXPORT void simple_set_index(struct array *a,struct svalue *ind,struct svalue *s)   {    switch (ind->type) {    case T_INT: {    INT_TYPE p = ind->u.integer;    INT_TYPE i = p < 0 ? p + a->size : p;    if(i<0 || i>=a->size) {    if (a->size) {    Pike_error("Index %"PRINTPIKEINT"d is out of array range " -  "%"PRINTPTRDIFFT"d..%"PRINTPTRDIFFT"d.\n", -  p, -a->size, a->size-1); +  "%d..%d.\n", p, -a->size, a->size-1);    } else {    Pike_error("Attempt to index the empty array with %"PRINTPIKEINT"d.\n", p);    }    }    array_set_index(a,i,s);    break;    }       case T_STRING:    {
pike.git/src/array.c:1281:   {    INT_TYPE i, p;    if(ind->type != T_INT)    Pike_error("Expected integer as array index, got %s.\n",    get_name_of_type (ind->type));    p = ind->u.integer;    i = p < 0 ? p + a->size : p;    if(i<0 || i>=a->size) {    if (a->size) {    Pike_error("Index %"PRINTPIKEINT"d is out of array range " -  "%"PRINTPTRDIFFT"d..%"PRINTPTRDIFFT"d.\n", -  p, -a->size, a->size-1); +  "%d..%d.\n", p, -a->size, a->size-1);    } else {    Pike_error("Attempt to index the empty array with %"PRINTPIKEINT"d.\n", p);    }    }    return low_array_get_item_ptr(a,i,t);   }      /*    * organize an array of INT32 to specify how to zip two arrays together    * to maintain the order.
pike.git/src/array.c:2148:    INT32 e;    struct svalue *argp = Pike_sp-args;    TYPE_FIELD new_types = 0;    struct array *cycl;    DECLARE_CYCLIC();       check_array_for_destruct(a);    check_stack(120 + args + 1);       /* FIXME: Ought to use a better key on the arguments below. */ -  if (!(cycl = (struct array *)BEGIN_CYCLIC(a, args))) { +  if (!(cycl = (struct array *)BEGIN_CYCLIC(a, (ptrdiff_t) args))) {    BEGIN_AGGREGATE_ARRAY(a->size) {    SET_CYCLIC_RET(Pike_sp[-1].u.array);    for (e=0;e<a->size;e++) {    assign_svalues_no_free(Pike_sp, argp, args, BIT_MIXED);    Pike_sp+=args;    apply_svalue(ITEM(a)+e,args);    new_types |= 1 << Pike_sp[-1].type;    DO_AGGREGATE_ARRAY(120);    }    }