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 2004/09/16 11:51:28 grubba Exp $ + || $Id: array.c,v 1.164 2004/09/16 17:32:09 grubba 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 2004/09/16 11:51:28 grubba Exp $"); + RCSID("$Id: array.c,v 1.164 2004/09/16 17:32:09 grubba 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:375:    (v->size-index) * sizeof(struct svalue));    ITEM(v)[index].type=T_INT;   #ifdef __CHECKER__    ITEM(v)[index].subtype=0;    ITEM(v)[index].u.refs=0;   #endif    v->size++;    }else{    struct array *ret;    -  ret=allocate_array_no_init(v->size+1, (v->size >> 3) + 1); +  ret = array_set_flag(allocate_array_no_init(v->size+1, (v->size >> 3) + 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, sizeof(struct svalue) * (v->size-index));    ITEM(ret)[index].type=T_INT;   #ifdef __CHECKER__    ITEM(ret)[index].subtype=0;    ITEM(ret)[index].u.refs=0;   #endif    v->size=0;
pike.git/src/array.c:1332:    return ret;       case PIKE_ARRAY_OP_SUB:    ptr=ret=(INT32 *)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));    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)
pike.git/src/array.c:2110:   PMOD_EXPORT struct array *copy_array_recursively(struct array *a,    struct mapping *m)   {    struct array *ret;    struct svalue aa, bb;      #ifdef PIKE_DEBUG    if(d_flag > 1) array_check_type_field(a);   #endif    +  if (!a->size) { +  add_ref(&empty_array); +  return array_set_flag(&empty_array, a->flags & ~ARRAY_LVALUE); +  } +     ret=allocate_array_no_init(a->size,0);       aa.type = T_ARRAY;    aa.subtype = 0;    aa.u.array = a;    bb.type = T_ARRAY;    bb.subtype = 0;    bb.u.array = ret;    low_mapping_insert(m, &aa, &bb, 1);   
pike.git/src/array.c:2183:       tmp0 = ITEM(a);    tmp1 = ITEM(a) + a->size;    for(e = a->size>>1; 0 < e; e--)    {    swap = *tmp0;    *(tmp0++) = *(--tmp1);    *tmp1 = swap;    }    +  /* FIXME: What about the flags field? */ +     add_ref(a);    return a;    }       ret=allocate_array_no_init(a->size,0);    for(e=0;e<a->size;e++)    assign_svalue_no_free(ITEM(ret)+e,ITEM(a)+a->size+~e);    ret->type_field = a->type_field;    return ret;   }