pike.git / src / mapping.c

version» Context lines:

pike.git/src/mapping.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: mapping.c,v 1.63 2000/02/09 07:29:36 hubbe Exp $"); + RCSID("$Id: mapping.c,v 1.64 2000/02/09 18:50:19 hubbe Exp $");   #include "main.h"   #include "object.h"   #include "mapping.h"   #include "svalue.h"   #include "array.h"   #include "pike_macros.h"   #include "language.h"   #include "error.h"   #include "pike_memory.h"   #include "dynamic_buffer.h"
pike.git/src/mapping.c:153:    md->refs=0;    md->valrefs=0;    md->hardlinks=0;    md->num_keypairs=size;    }else{    md=&empty_data;    }    add_ref(md);    m->data=md;   #ifdef PIKE_DEBUG -  m->size = md->size; +  m->debug_size = md->size;   #endif   }      /* This function allocates an empty mapping with room for 'size' values    */   struct mapping *debug_allocate_mapping(int size)   {    struct mapping *m;       GC_ALLOC();
pike.git/src/mapping.c:316:    for(e=0;e<md->hashsize;e++)    mapping_rehash_backwards_evil(new_md, md->hash[e]);       free((char *)md);    }      #ifdef PIKE_DEBUG    if(m->data->size != tmp)    fatal("Rehash failed, size not same any more.\n");    -  m->size = m->data->size; +  m->debug_size = m->data->size;   #endif      #ifdef PIKE_DEBUG    if(d_flag>1) check_mapping(m);   #endif       return m;   }      /*
pike.git/src/mapping.c:616:    md->free_list=k->next;    k->next=md->hash[h];    md->hash[h]=k;    md->ind_types |= 1 << key->type;    md->val_types |= 1 << val->type;    assign_svalue_no_free(& k->ind, key);    assign_svalue_no_free(& k->val, val);    k->hval = h2;    md->size++;   #ifdef PIKE_DEBUG -  m->size++; +  m->debug_size++;   #endif      #ifdef PIKE_DEBUG    if(d_flag>1) check_mapping(m);   #endif   }      void mapping_insert(struct mapping *m,    struct svalue *key,    struct svalue *val)
pike.git/src/mapping.c:726:    md->hash[h]=k;    assign_svalue_no_free(& k->ind, key);    k->val.type=T_INT;    k->val.subtype=NUMBER_NUMBER;    k->val.u.integer=0;    k->hval = h2;    md->ind_types |= 1 << key->type;    md->val_types |= BIT_INT;    md->size++;   #ifdef PIKE_DEBUG -  m->size++; +  m->debug_size++;   #endif      #ifdef PIKE_DEBUG    if(d_flag > 1) check_mapping_type_fields(m);   #endif       return & ( k->val.u );   }      void map_delete_no_free(struct mapping *m,
pike.git/src/mapping.c:801:    else    free_svalue(& k->val);       k->ind.type=T_INT;    k->val.type=T_INT;       k->next=md->free_list;    md->free_list=k;    md->size--;   #ifdef PIKE_DEBUG -  m->size--; +  m->debug_size--;   #endif       if(md->size < (md->hashsize + 1) * MIN_LINK_LENGTH)    {    debug_malloc_touch(m);    rehash(m, MAP_SLOTS(m->data->size));    }      #ifdef PIKE_DEBUG    if(d_flag>1) check_mapping(m);
pike.git/src/mapping.c:855:    !k->ind.u.object->prog)    {    PREPARE_FOR_INDEX_CHANGE2();    *prev=k->next;    free_svalue(& k->ind);    free_svalue(& k->val);    k->next=md->free_list;    md->free_list=k;    md->size--;   #ifdef PIKE_DEBUG -  m->size++; +  m->debug_size++;   #endif    }else{    val_types |= 1 << k->val.type;    ind_types |= 1 << k->ind.type;    prev=&k->next;    }    }    }    if(MAP_SLOTS(md->size) < md->hashsize * MIN_LINK_LENGTH)    {
pike.git/src/mapping.c:1566:    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));    ret->flags=m->flags;    doing.pointer_b=ret;       check_stack(2);       md=m->data;
pike.git/src/mapping.c:1692: Inside #if defined(PIKE_DEBUG)
      if(!m->data)    fatal("Mapping has no data block.\n");       if (!m->data->refs)    fatal("Mapping data block has zero refs.\n");       if(m->next && m->next->prev != m)    fatal("Mapping ->next->prev != mapping.\n");    -  if(m->size != md->size) +  if(m->debug_size != md->size)    fatal("Mapping zapping detected!\n");       if(m->prev)    {    if(m->prev->next != m)    fatal("Mapping ->prev->next != mapping.\n");    }else{    if(first_mapping != m)    fatal("Mapping ->prev == 0 but first_mapping != mapping.\n");    }
pike.git/src/mapping.c:1898:    gc_do_free(k->ind.u.refs)))    {    PREPARE_FOR_INDEX_CHANGE();    *prev=k->next;    free_svalue(& k->ind);    free_svalue(& k->val);    k->next=md->free_list;    md->free_list=k;    md->size--;   #ifdef PIKE_DEBUG -  m->size++; +  m->debug_size++;   #endif    }else{    prev=&k->next;    }    }    }    if(MAP_SLOTS(md->size) < md->hashsize * MIN_LINK_LENGTH)    {    debug_malloc_touch(m);    rehash(m, MAP_SLOTS(md->size));
pike.git/src/mapping.c:1981:    {    md->hash[e]=k->next;    k->next=md->free_list;    md->free_list=k;    free_svalue(&k->ind);    free_svalue(&k->val);    }    }    md->size=0;   #ifdef PIKE_DEBUG -  m->size=0; +  m->debug_size=0;   #endif       next=m->next;       /* free_mapping(m); */    }    free_all_mapping_blocks();   }