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.178 2004/12/22 18:46:14 grubba Exp $ + || $Id: array.c,v 1.179 2005/02/14 15:54:59 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:174:   /**    * Decrement the references (and free if unused) an array if it is not null.    */   PMOD_EXPORT void do_free_array(struct array *a)   {    if (a)    free_array(a);   }      /** -  * Set flags on an array. If the array is empty, +  * Set the flags on an array. If the array is empty then only the +  * weak flag is significant.    */   PMOD_EXPORT struct array *array_set_flags(struct array *a, int flags)   {    if (a->size)    a->flags = flags;    else {    free_array(a); -  switch (flags) { -  case 0: -  add_ref(a = &empty_array); break; -  case ARRAY_WEAK_FLAG: -  add_ref(a = &weak_empty_array); break; -  default: -  Pike_fatal("Invalid flags %x\n", flags); +  if (flags & ARRAY_WEAK_FLAG) +  add_ref(a = &weak_empty_array); +  else +  add_ref(a = &empty_array);    } -  } +     return a;   }         /**    * Extract an svalue from an array. This function frees the contents of    * of the svalue 's' and replaces it with a copy of the    * contents from index 'index' in the array 'v'.    *    * @param index The index of the array to be extracted.
pike.git/src/array.c:2199:   {    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 & ~ARRAY_LVALUE); +  return array_set_flags(&empty_array, a->flags);    }       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;