pike.git / src / mapping.c

version» Context lines:

pike.git/src/mapping.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: mapping.c,v 1.180 2004/04/15 00:12:04 nilsson Exp $ + || $Id: mapping.c,v 1.181 2004/05/28 16:08:24 grubba Exp $   */      #include "global.h" - RCSID("$Id: mapping.c,v 1.180 2004/04/15 00:12:04 nilsson Exp $"); + RCSID("$Id: mapping.c,v 1.181 2004/05/28 16:08:24 grubba Exp $");   #include "main.h"   #include "object.h"   #include "mapping.h"   #include "svalue.h"   #include "array.h"   #include "pike_macros.h"   #include "pike_error.h"   #include "pike_memory.h"   #include "dynamic_buffer.h"   #include "interpret.h"
pike.git/src/mapping.c:641:      /* This function inserts key:val into the mapping m.    * Same as doing m[key]=val; in pike.    *    * overwrite:    * 0: Do not replace the value if the entry exists.    * 1: Replace the value if the entry exists.    * 2: Replace both the index and the value if the entry exists.    */   PMOD_EXPORT void low_mapping_insert(struct mapping *m, -  struct svalue *key, -  struct svalue *val, +  const struct svalue *key, +  const struct svalue *val,    int overwrite)   {    unsigned INT32 h,h2;    struct keypair *k, **prev;    struct mapping_data *md, *omd;      #ifdef PIKE_DEBUG    if(m->data->refs <=0)    Pike_fatal("Zero refs in mapping->data\n");   #endif
pike.git/src/mapping.c:752: Inside #if defined(MAPPING_SIZE_DEBUG)
   if(m->data ==md)    m->debug_size++;   #endif      #ifdef PIKE_DEBUG    if(d_flag>1) check_mapping(m);   #endif   }      PMOD_EXPORT void mapping_insert(struct mapping *m, -  struct svalue *key, -  struct svalue *val) +  const struct svalue *key, +  const struct svalue *val)   {    low_mapping_insert(m,key,val,1);   }      /* Inline the above in this file. */   #define mapping_insert(M, KEY, VAL) low_mapping_insert ((M), (KEY), (VAL), 1)      PMOD_EXPORT union anything *mapping_get_item_ptr(struct mapping *m,    struct svalue *key,    TYPE_T t)
pike.git/src/mapping.c:1033:    rehash(m, MAP_SLOTS(md->size));    }      #ifdef PIKE_DEBUG    if(d_flag>1) check_mapping(m);   #endif    }   }      PMOD_EXPORT struct svalue *low_mapping_lookup(struct mapping *m, -  struct svalue *key) +  const struct svalue *key)   {    unsigned INT32 h,h2;    struct keypair *k=0, **prev=0;    struct mapping_data *md, *omd;      #ifdef PIKE_DEBUG    if(m->data->refs <=0)    Pike_fatal("Zero refs in mapping->data\n");    if(d_flag>1) check_mapping(m);   #endif
pike.git/src/mapping.c:2003:    for(e=-args;e<0;e+=2) low_mapping_insert(m, Pike_sp+e, Pike_sp+e+1, 2);    pop_n_elems(args);   #ifdef PIKE_DEBUG    if(d_flag)    check_mapping(m);   #endif    push_mapping(m);   }      PMOD_EXPORT struct mapping *copy_mapping_recursively(struct mapping *m, -  struct processing *p) +  struct mapping *p)   { -  struct processing doing; +     struct mapping *ret;    INT32 e;    struct keypair *k;    struct mapping_data *md; -  +  struct svalue aa, bb;      #ifdef PIKE_DEBUG    if(m->data->refs <=0)    Pike_fatal("Zero refs in mapping->data\n");   #endif    -  doing.next=p; -  doing.pointer_a=(void *)m; -  for(;p;p=p->next) -  { -  if(p->pointer_a == (void *)m) -  { -  add_ref(ret=(struct mapping *)p->pointer_b); -  return ret; -  } -  } -  +    #ifdef PIKE_DEBUG    if(d_flag > 1) check_mapping_type_fields(m);   #endif       if(!((m->data->val_types | m->data->ind_types) & BIT_COMPLEX))    return copy_mapping(m);       ret=allocate_mapping(MAP_SLOTS(m->data->size)); -  doing.pointer_b=ret; +     -  +  aa.type = T_MAPPING; +  aa.subtype = 0; +  aa.u.mapping = m; +  bb.type = T_MAPPING; +  bb.subtype = 0; +  bb.u.mapping = ret; +  mapping_insert(p, &aa, &bb); +     ret->data->flags = m->data->flags;       check_stack(2);       md=m->data;    md->valrefs++;    add_ref(md);    NEW_MAPPING_LOOP(md)    { -  copy_svalues_recursively_no_free(Pike_sp,&k->ind, 1, &doing); +  copy_svalues_recursively_no_free(Pike_sp,&k->ind, 1, p);    Pike_sp++;    dmalloc_touch_svalue(Pike_sp-1); -  copy_svalues_recursively_no_free(Pike_sp,&k->val, 1, &doing); +  copy_svalues_recursively_no_free(Pike_sp,&k->val, 1, p);    Pike_sp++;    dmalloc_touch_svalue(Pike_sp-1);       low_mapping_insert(ret, Pike_sp-2, Pike_sp-1, 2);    pop_n_elems(2);    }    md->valrefs--;    free_mapping_data(md);       return ret;