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.162 2003/02/01 15:43:50 mast Exp $ + || $Id: mapping.c,v 1.163 2003/03/14 15:50:44 grubba Exp $   */      #include "global.h" - RCSID("$Id: mapping.c,v 1.162 2003/02/01 15:43:50 mast Exp $"); + RCSID("$Id: mapping.c,v 1.163 2003/03/14 15:50:44 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:221:   {    struct mapping *m;       m=alloc_mapping();       GC_ALLOC(m);       INITIALIZE_PROT(m);    init_mapping(m,size,0);    -  m->refs = 1; +  m->refs = 0; +  add_ref(m); /* For DMALLOC... */       DOUBLELINK(first_mapping, m);       return m;   }         PMOD_EXPORT void really_free_mapping_data(struct mapping_data *md)   {    INT32 e;
pike.git/src/mapping.c:438:    }   #else /* PIKE_MAPPING_KEYPAIR_LOOP */    for(e=0;e<nmd->size;e++)    {    RELOC(keypairs[e].next);    add_ref_svalue(& keypairs[e].ind);    add_ref_svalue(& keypairs[e].val);    }   #endif /* PIKE_MAPPING_KEYPAIR_LOOP */    -  nmd->refs=1; +  nmd->refs=0; +  add_ref(nmd); /* For DMALLOC... */    nmd->valrefs=0;    nmd->hardlinks=0;       if(md->hardlinks)    {   #ifdef PIKE_DEBUG    if(md->refs <= 0 || md->valrefs<=0)    Pike_fatal("Hardlink without refs/valrefs!\n");   #endif    md->hardlinks--;    md->valrefs--;    } -  md->refs--; +  sub_ref(md);       return nmd;   }      #define MAPPING_DATA_IN_USE(MD) ((MD)->refs != (MD)->hardlinks + 1)      #define LOW_FIND(FUN, KEY, FOUND, NOT_FOUND) do { \    md=m->data; \    add_ref(md); \    if(md->hashsize) \
pike.git/src/mapping.c:568:      /* Assumes md is locked */   #define COPYMAP() do { \    ptrdiff_t off; \    m->data=copy_mapping_data(m->data); \    debug_malloc_touch(m->data); \    off=((char *)m->data)-((char *)md); \    LOW_RELOC(k); \    free_mapping_data(md); \    md=m->data; \ -  md->refs++; \ +  add_ref(md); \   }while(0)      #define PREPARE_FOR_DATA_CHANGE() \    if(md->valrefs) COPYMAP()      #define PREPARE_FOR_INDEX_CHANGE() \    if(md->refs>1) COPYMAP()      /* This function brings the type fields in the mapping up to speed.    * I only use it when the type fields MUST be correct, which is not
pike.git/src/mapping.c:1337:   #endif       n=allocate_mapping(0);    if(!m_sizeof(m)) return n; /* done */    debug_malloc_touch(n->data);    free_mapping_data(n->data);    n->data=m->data;   #ifdef MAPPING_SIZE_DEBUG    n->debug_size=n->data->size;   #endif -  n->data->refs++; +  add_ref(n->data);    n->data->valrefs++;    n->data->hardlinks++;    debug_malloc_touch(n->data);    return n;   }      #endif      PMOD_EXPORT struct mapping *merge_mappings(struct mapping *a, struct mapping *b, INT32 op)   {
pike.git/src/mapping.c:1864:       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);    Pike_sp++; +  dmalloc_touch_svalue(Pike_sp-1);    copy_svalues_recursively_no_free(Pike_sp,&k->val, 1, &doing);    Pike_sp++; -  +  dmalloc_touch_svalue(Pike_sp-1);       mapping_insert(ret, Pike_sp-2, Pike_sp-1);    pop_n_elems(2);    }    md->valrefs--;    free_mapping_data(md);       return ret;   }