pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.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: encode.c,v 1.171 2003/04/02 19:22:43 mast Exp $ + || $Id: encode.c,v 1.172 2003/04/28 00:32:43 mast Exp $   */      #include "global.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "mapping.h"
pike.git/src/encode.c:20:   #include "operators.h"   #include "builtin_functions.h"   #include "module_support.h"   #include "fsort.h"   #include "threads.h"   #include "stuff.h"   #include "version.h"   #include "bignum.h"   #include "pikecode.h"    - RCSID("$Id: encode.c,v 1.171 2003/04/02 19:22:43 mast Exp $"); + RCSID("$Id: encode.c,v 1.172 2003/04/28 00:32:43 mast Exp $");      /* #define ENCODE_DEBUG */      /* Use the old encoding method for programs. */   /* #define OLD_PIKE_ENCODE_PROGRAM */      #ifdef ENCODE_DEBUG   /* Pass a nonzero integer as the third arg to encode_value,    * encode_value_canonic and decode_value to activate this debug. */   #define EDB(N,X) do { debug_malloc_touch(data); if (data->debug>=N) {X;} } while (0)
pike.git/src/encode.c:2154:       tmp.type = T_INT;    tmp = data->counter;    data->counter.u.integer++;    }    break;       case TAG_ARRAY:    {    struct array *a; +  TYPE_FIELD types;    if(num < 0)    Pike_error("Failed to decode array. (array size is negative)\n");       /* Heruetical */    if(data->ptr + num > data->len)    Pike_error("Failed to decode array. (not enough data)\n");       EDB(2,fprintf(stderr, "%*sDecoding array of size %d to <%d>\n",    data->depth, "", num, data->counter.u.integer));       SETUP_DECODE_MEMOBJ(T_ARRAY, array, a, allocate_array(num),    free_svalues(ITEM(a), a->size, a->type_field));    -  +  types = 0;    for(e=0;e<num;e++)    {    decode_value2(data); -  ITEM(a)[e]=Pike_sp[-1]; -  Pike_sp--; -  dmalloc_touch_svalue(Pike_sp); +  stack_pop_to_no_free (ITEM(a) + e); +  types |= 1 << ITEM(a)[e].type;    } -  +  a->type_field = types;    ref_push_array(a);   #ifdef ENCODE_DEBUG    data->depth -= 2;   #endif    return;    }       case TAG_MAPPING:    {    struct mapping *m;
pike.git/src/encode.c:2214: Inside #if defined(ENCODE_DEBUG)
  #ifdef ENCODE_DEBUG    data->depth -= 2;   #endif    return;    }       case TAG_MULTISET:    {    struct multiset *m;    struct array *a; +  TYPE_FIELD types;    if(num<0)    Pike_error("Failed to decode multiset. (multiset size is negative)\n");       /* Heruetical */    if(data->ptr + num > data->len)    Pike_error("Failed to decode multiset. (not enough data)\n");       /* NOTE: This code knows stuff about the implementation of multisets...*/       EDB(2,fprintf(stderr, "%*sDecoding multiset of size %d to <%d>\n",
pike.git/src/encode.c:2236: Inside #if defined(PIKE_NEW_MULTISETS)
   SETUP_DECODE_MEMOBJ (T_MULTISET, multiset, m,    allocate_multiset (0, 0, NULL), ;);    /* FIXME: This array could be avoided by building the multiset directly. */    a = low_allocate_array (num, 0);   #else    SETUP_DECODE_MEMOBJ(T_MULTISET, multiset, m,    allocate_multiset(low_allocate_array(num, 0)), ;);    a=m->ind;   #endif    +  types = 0;    for(e=0;e<num;e++)    {    decode_value2(data); -  assign_svalue(a->item+e , Pike_sp-1); -  pop_stack(); -  dmalloc_touch_svalue(Pike_sp); +  stack_pop_to_no_free (ITEM(a) + e); +  types |= 1 << ITEM(a)[e].type;    } -  array_fix_type_field(a); +  a->type_field = types;   #ifdef PIKE_NEW_MULTISETS    {    struct multiset *l = mkmultiset (a);    free_array (a);    /* This special case is handled efficiently by merge_multisets. */    merge_multisets (m, l, PIKE_MERGE_DESTR_A | PIKE_ARRAY_OP_ADD);    free_multiset (l);    }   #else    order_multiset(m);
pike.git/src/encode.c:2462:    prog_code->u.string->str);    }    Pike_error("Failed to decode program.\n");    }    pop_n_elems(2);    push_undefined();    break;    }    /* Remove the extra entry from the stack. */    ref_push_program(p); -  stack_pop_n_elems_keep_top(2); +  stack_pop_2_elems_keep_top();    break;    }       case 1:    {    int d, in;    size_t size=0;    char *dat=0;    struct program *p;    struct object *placeholder=0;