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.185 2006/02/19 18:29:25 nilsson Exp $ + || $Id: array.c,v 1.186 2006/02/20 12:31:32 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:436:    struct array *a;      #ifdef PIKE_DEBUG    if(v->refs>2) /* Odd, but has to be two */    Pike_fatal("Array shrink on array with many references.\n");       if(size > v->size)    Pike_fatal("Illegal argument to array_shrink.\n");   #endif    +  if (size == v->size) return v; +     if( !size )    {    free_array(v); -  +  /* FIXME: What about weak markers etc? */    add_ref(&empty_array);    return &empty_array;    }       /* Free items outside the new array. */    free_svalues(ITEM(v) + size, v->size - size, v->type_field); -  +  v->size=size;       if(size*4 < v->malloced_size + 4) /* Should we realloc it? */    {    a = array_set_flags(allocate_array_no_init(size, 0), v->flags);    if (a->size) {    a->type_field = v->type_field;    }       MEMCPY(ITEM(a), ITEM(v), size*sizeof(struct svalue));    v->size=0;    free_array(v);    return a;    }else{ -  v->size=size; +     return v;    }   }      /**    * Resize an array destructively.    */   PMOD_EXPORT struct array *resize_array(struct array *a, INT32 size)   {   #ifdef PIKE_DEBUG