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.60 2000/02/04 19:25:10 hubbe Exp $"); + RCSID("$Id: mapping.c,v 1.61 2000/02/04 20:16:16 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:22:   #include "stralloc.h"   #include "security.h"   #include "block_alloc.h"      #define AVG_LINK_LENGTH 4   #define MIN_LINK_LENGTH 1   #define MAP_SLOTS(X) ((X)?((X)+((X)>>4)+8):0)      struct mapping *first_mapping;    + #define unlink_mapping_data(M) do{ \ +  struct mapping_data *md_=(M); \ +  if(md_->hardlinks) { md_->hardlinks--; md_->valrefs--; } \ +  free_mapping_data(M); \ + }while(0) +  +    #define MD_KEYPAIRS(MD, HSIZE) \    ( (struct keypair *)DO_ALIGN( (long) (((struct mapping_data *)(MD))->hash + HSIZE), ALIGNOF(struct keypair)) )      #define MAPPING_DATA_SIZE(HSIZE, KEYPAIRS) \    (long)( MD_KEYPAIRS(0, HSIZE) + KEYPAIRS )            #undef EXIT_BLOCK   #define EXIT_BLOCK(m) \    INT32 e; \   DO_IF_DEBUG( \    if(m->refs) \    fatal("really free mapping on mapping with nonzero refs.\n"); \   ) \    \    FREE_PROT(m); \    \ -  if(m->data->hardlinks) \ -  { \ -  m->data->hardlinks--; \ -  m->data->valrefs--; \ -  } \ -  free_mapping_data(m->data); \ +  unlink_mapping_data(m->data); \    \    if(m->prev) \    m->prev->next = m->next; \    else \    first_mapping = m->next; \    \    if(m->next) m->next->prev = m->prev; \    \    GC_FREE();   
pike.git/src/mapping.c:298:    debug_malloc_touch(m);    new_md=m->data;       /* This operation is now 100% atomic - no locking required */    if(md->refs>1)    {    /* good */    for(e=0;e<md->hashsize;e++)    mapping_rehash_backwards_good(new_md, md->hash[e]);    -  if(md->hardlinks) -  { -  md->hardlinks--; -  md->valrefs--; -  } -  free_mapping_data(md); +  unlink_mapping_data(md);    }else{    /* 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)
pike.git/src/mapping.c:1844:    struct keypair *k,**prev;    struct mapping *m,*next;    struct mapping_data *md;       for(m=first_mapping;m;m=next)    {    check_mapping_for_destruct(m);    if(gc_do_free(m))    {    add_ref(m); -  md=m->data; -  -  /* no locking required -  * -  * FIXME: is it possible that md->refs might not be zero here? -  * for now I will assume it is not possible... -  */ -  for(e=0;e<md->hashsize;e++) -  { -  k=md->hash[e]; -  while(k) -  { -  free_svalue(&k->ind); -  free_svalue(&k->val); -  -  if(k->next) -  { -  k = k->next; -  } else { -  k->next=md->free_list; -  md->free_list=md->hash[e]; -  md->hash[e]=0; -  break; -  } -  } -  } -  md->size=0; -  +  unlink_mapping_data(m->data); +  m->data=&empty_data; +  m->data->refs++;    next=m->next;       free_mapping(m);    }    else if(m->flags & MAPPING_FLAG_WEAK)    {    add_ref(m);    md=m->data;    /* no locking required (no is_eq) */    for(e=0;e<md->hashsize;e++)