Branch: Tag:

2000-08-27

2000-08-27 12:22:33 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Fixed multiset decoding [Bug 19 (#19)].

Rev: src/encode.c:1.69

25:   #include "version.h"   #include "bignum.h"    - RCSID("$Id: encode.c,v 1.68 2000/08/17 18:50:32 grubba Exp $"); + RCSID("$Id: encode.c,v 1.69 2000/08/27 12:22:33 grubba Exp $");      /* #define ENCODE_DEBUG */   
1148:    case TAG_MULTISET:    {    struct multiset *m; +  struct array *a;    if(num<0)    error("Failed to decode string. (multiset size is negative)\n");   
1155:    if(data->ptr + num > data->len)    error("Failed to decode multiset. (not enough data)\n");    -  m=mkmultiset(low_allocate_array(0, num)); -  tmp.type=T_MULTISET; -  tmp.u.multiset=m; +  /* NOTE: This code knows stuff about the implementation of multisets...*/ +  a = low_allocate_array(num, 0); +  m = allocate_multiset(a); +  tmp.type = T_MULTISET; +  tmp.u.multiset = m;    mapping_insert(data->decoded, & data->counter, &tmp);    data->counter.u.integer++; -  m->refs--; +     debug_malloc_touch(m);       for(e=0;e<num;e++)    {    decode_value2(data); -  multiset_insert(m, Pike_sp-1); -  pop_stack(); +  a->item[e] = sp[-1]; +  sp--; +  dmalloc_touch_svalue(sp);    } -  ref_push_multiset(m); +  array_fix_type_field(a); +  order_multiset(m); +  push_multiset(m);    return;    }