pike.git / src / mapping.c

version» Context lines:

pike.git/src/mapping.c:1470:   #endif       m=allocate_mapping(MAP_SLOTS(ind->size));    i=ITEM(ind);    v=ITEM(val);    for(e=0;e<ind->size;e++) low_mapping_insert(m, i++, v++, 2);       return m;   }    - #if 0 - PMOD_EXPORT struct mapping *copy_mapping(struct mapping *m) - { -  INT32 e; -  struct mapping *n; -  struct keypair *k; -  struct mapping_data *md; -  -  md=m->data; -  n=allocate_mapping(MAP_SLOTS(md->size)); -  -  md->valrefs++; -  add_ref(md); -  NEW_MAPPING_LOOP(md) mapping_insert(n, &k->ind, &k->val); -  md->valrefs--; -  free_mapping_data(md); -  -  return n; - } - #else -  +    /* deferred mapping copy! */   PMOD_EXPORT struct mapping *copy_mapping(struct mapping *m)   {    struct mapping *n;      #ifdef PIKE_DEBUG    if(m->data->refs <=0)    Pike_fatal("Zero refs in mapping->data\n");   #endif   
pike.git/src/mapping.c:1515: Inside #if defined(MAPPING_SIZE_DEBUG)
  #ifdef MAPPING_SIZE_DEBUG    n->debug_size=n->data->size;   #endif    add_ref(n->data);    n->data->valrefs++;    n->data->hardlinks++;    debug_malloc_touch(n->data);    return n;   }    - #endif -  +    /* copy_mapping() for when destructive operations are ok.    *    * Note: It destructive operations on the resulting mapping *will*    * affect eg NEW_MAPPING_LOOP() on the original mapping.    */   static struct mapping *destructive_copy_mapping(struct mapping *m)   {    if ((m->refs == 1) && !m->data->hardlinks &&    !(m->data->flags & MAPPING_WEAK)) {    /* We may perform destructive operations on the mapping. */