Branch: Tag:

2004-05-28

2004-05-28 16:08:24 by Henrik Grubbström (Grubba) <grubba@grubba.org>

copy_svalues_recursively_no_free() et al now preserve identity relations.
Fixes [bug 3693 (#3693)].
Note that this is a (minor) API change (struct processing * ==> struct mapping *).
Added a few const's.

Rev: src/array.c:1.160
Rev: src/array.h:1.61
Rev: src/mapping.c:1.181
Rev: src/mapping.h:1.56
Rev: src/multiset.c:1.86
Rev: src/multiset.h:1.35
Rev: src/svalue.c:1.194
Rev: src/svalue.h:1.129

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.159 2004/05/13 23:28:49 nilsson Exp $ + || $Id: array.c,v 1.160 2004/05/28 16:08:24 grubba Exp $   */      #include "global.h"
26:   #include "cyclic.h"   #include "multiset.h"    - RCSID("$Id: array.c,v 1.159 2004/05/13 23:28:49 nilsson Exp $"); + RCSID("$Id: array.c,v 1.160 2004/05/28 16:08:24 grubba Exp $");      PMOD_EXPORT struct array empty_array=   {
2096:    return low_end_shared_string(ret);   }    - PMOD_EXPORT struct array *copy_array_recursively(struct array *a,struct processing *p) + PMOD_EXPORT struct array *copy_array_recursively(struct array *a, +  struct mapping *m)   { -  struct processing doing; +     struct array *ret; -  +  struct svalue aa, bb;      #ifdef PIKE_DEBUG    if(d_flag > 1) array_check_type_field(a);   #endif    -  doing.next=p; -  doing.pointer_a=(void *)a; -  for(;p;p=p->next) -  { -  if(p->pointer_a == (void *)a) -  { -  ret=(struct array *)p->pointer_b; -  add_ref(ret); -  return ret; -  } -  } -  +     ret=allocate_array_no_init(a->size,0); -  doing.pointer_b=(void *)ret; +     -  +  aa.type = T_ARRAY; +  aa.subtype = 0; +  aa.u.array = a; +  bb.type = T_ARRAY; +  bb.subtype = 0; +  bb.u.array = ret; +  low_mapping_insert(m, &aa, &bb); +     ret->flags = a->flags & ~ARRAY_LVALUE;    -  copy_svalues_recursively_no_free(ITEM(ret),ITEM(a),a->size,&doing); +  copy_svalues_recursively_no_free(ITEM(ret),ITEM(a),a->size,m);       ret->type_field=a->type_field;    return ret;