pike.git / src / mapping.c

version» Context lines:

pike.git/src/mapping.c:1639:   #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;   }    + PMOD_EXPORT void clear_mapping(struct mapping *m) + { +  struct mapping_data *md = m->data; +  int flags = md->flags; +  +  if (!md->size) return; +  unlink_mapping_data(md); +  +  switch (flags & MAPPING_WEAK) { +  case 0: md = &empty_data; break; +  case MAPPING_WEAK_INDICES: md = &weak_ind_empty_data; break; +  case MAPPING_WEAK_VALUES: md = &weak_val_empty_data; break; +  default: md = &weak_both_empty_data; break; +  } +  +  /* FIXME: Increment hardlinks & valrefs? +  * NB: init_mapping() doesn't do this. +  */ +  add_ref(md); +  /* gc_init_marker(md); */ +  +  m->data = md; + #ifdef MAPPING_SIZE_DEBUG +  m->debug_size = md->size; + #endif + } +    /* 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