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.227 2010/07/01 09:16:05 grubba Exp $ + || $Id: array.c,v 1.228 2010/07/11 12:30:45 jonasw 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:73:    *    * @param size The size of the new array, in elements.    * @param extra_space The number of extra elements space    * should be reserved for.    * @return A pointer to the allocated array struct.    */   PMOD_EXPORT struct array *real_allocate_array(ptrdiff_t size,    ptrdiff_t extra_space)   {    struct array *v; -  ptrdiff_t e; +        if(size+extra_space == 0)    {    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.git/src/array.c:109:    else    v->type_field = 0;    v->flags=0;       v->malloced_size = DO_NOT_WARN((INT32)(size + extra_space));    v->item=v->real_item;    v->size = DO_NOT_WARN((INT32)size);    INIT_PIKE_MEMOBJ(v);    DOUBLELINK (first_array, v);    -  MEMSET(v->real_item, 0, sizeof(struct svalue) * size); -  for(e=0;e<size;e++) { -  v->item[e].type=T_INT; +  { +  struct svalue *item = ITEM(v); +  struct svalue *item_end = item + v->size; +  while (item < item_end) +  *item++ = svalue_int_zero;    }       return v;   }      /**    * Free an array without freeing the values inside it.    * Any values inside of the array will be kept.    * @param v The array to be freed.    */
pike.git/src/array.c:2425:    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_flags(&empty_array, a->flags); +  ret = (a->flags & ARRAY_WEAK_FLAG) ? &weak_empty_array : &empty_array; +  add_ref(ret); +  return ret;    }       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;