Branch: Tag:

2008-07-04

2008-07-04 15:50:46 by Martin Stjernholm <mast@lysator.liu.se>

Handle the static empty arrays as input to resize_array, to avoid
special cases in calling code.

Rev: src/array.c:1.212

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.211 2008/07/01 09:36:28 mast Exp $ + || $Id: array.c,v 1.212 2008/07/04 15:50:46 mast Exp $   */      #include "global.h"
564:   }      /** -  * Resize an array destructively. +  * Resize an array destructively, with the exception that a may be one +  * of the static empty arrays.    */   PMOD_EXPORT struct array *resize_array(struct array *a, INT32 size)   {
573:   #endif       /* Ensure that one of the empty arrays are returned if size is zero. */ -  if (!size) return array_shrink (a, size); +  if (!size && a->malloced_size) return array_shrink (a, size);       if(a->size == size) return a;    if(size > a->size)