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.62 2000/02/06 01:49:54 hubbe Exp $"); + RCSID("$Id: mapping.c,v 1.63 2000/02/09 07:29:36 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:152:    md->size = 0;    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; + #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:312:    /* evil */    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;   #endif      #ifdef PIKE_DEBUG    if(d_flag>1) check_mapping(m);   #endif       return m;   }      /*
pike.git/src/mapping.c:377:       return nmd;   }      #define LOW_FIND(FUN, KEY, FOUND, NOT_FOUND) do { \    md=m->data; \    add_ref(md); \    if(md->hashsize) \    { \    h=h2 % md->hashsize; \ +  DO_IF_DEBUG( if(d_flag > 1) check_mapping_type_fields(m); ) \    if(md->ind_types & (1 << key->type)) \    { \    for(prev= md->hash + h;(k=*prev);prev=&k->next) \    { \    if(h2 == k->hval && FUN(& k->ind, KEY)) \    { \    FOUND; \    } \    } \    } \
pike.git/src/mapping.c:399:   }while(0)         #define LOW_FIND2(FUN, KEY, FOUND, NOT_FOUND) do { \    struct keypair *k2; \    md=m->data; \    add_ref(md); \    if(md->hashsize) \    { \    h=h2 % md->hashsize; \ +  DO_IF_DEBUG( if(d_flag > 1) check_mapping_type_fields(m); ) \    if(md->ind_types & (1 << key->type)) \    { \    k2=omd->hash[h2 % md->hashsize]; \    prev= md->hash + h; \    for(;(k=*prev) && k2;(prev=&k->next),(k2=k2->next)) \    if(!(h2 == k->hval && is_identical(&k2->ind, &k->ind))) \    break; \    for(;(k=*prev);prev=&k->next) \    { \    if(FUN(& k->ind, KEY)) \
pike.git/src/mapping.c:608:    k=md->free_list;    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++; + #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:715:    k->next=md->hash[h];    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++; + #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,    struct svalue *key,
pike.git/src/mapping.c:787:    to[0]=k->val;    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--; + #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);   #endif
pike.git/src/mapping.c:838:    if((k->ind.type == T_OBJECT || k->ind.type == T_FUNCTION) &&    !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++; + #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)    {    debug_malloc_touch(m);
pike.git/src/mapping.c:1547:    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;    }    }    +  if(d_flag > 1) check_mapping_type_fields(m);    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:1672: 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) +  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");    }       if(md->valrefs <0)
pike.git/src/mapping.c:1874:    k->ind.u.object->prog->flags & PROGRAM_NO_WEAK_FREE) &&    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++; + #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:1954:    while((k=md->hash[e]))    {    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; + #endif       next=m->next;       /* free_mapping(m); */    }    free_all_mapping_blocks();   }