Branch: Tag:

2006-02-20

2006-02-20 12:31:32 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Fixed ref-count error introduced in array_shrink().
Added minor optimization.
Added FIXME.

Rev: src/array.c:1.186

2:   || 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"
443:    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? */    {
465:    free_array(v);    return a;    }else{ -  v->size=size; +     return v;    }   }