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.211 2008/06/29 15:05:16 grubba Exp $ + || $Id: mapping.c,v 1.212 2008/07/16 15:47:08 grubba Exp $   */      #include "global.h"   #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 "pike_types.h"   #include "dynamic_buffer.h"   #include "interpret.h"   #include "las.h"   #include "gc.h"   #include "stralloc.h"   #include "pike_security.h"   #include "block_alloc.h"   #include "opcodes.h"   #include "stuff.h"   
pike.git/src/mapping.c:122: Inside #if defined(PIKE_DEBUG)
   INT32 e;    const struct keypair *k=0;    const struct mapping_data *md;    TYPE_FIELD ind_types, val_types;       ind_types=val_types=0;       md = m->data;    NEW_MAPPING_LOOP(md)    { +  if (k->val.type > MAX_TYPE) +  Pike_fatal("Invalid mapping keypair value type: %s\n", +  get_name_of_type(k->val.type));    val_types |= 1 << k->val.type; -  +  if (k->ind.type > MAX_TYPE) +  Pike_fatal("Invalid maping keypair index type: %s\n", +  get_name_of_type(k->ind.type));    ind_types |= 1 << k->ind.type;    }       if(val_types & ~(m->data->val_types))    Pike_fatal("Mapping value types out of order!\n");       if(ind_types & ~(m->data->ind_types))    Pike_fatal("Mapping indices types out of order!\n");   }   #endif
pike.git/src/mapping.c:1414:   #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. */ + /* 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. */    add_ref(m);    return m;    }    return copy_mapping(m);   }
pike.git/src/mapping.c:1491:    struct mapping_data *a_md = a->data;    struct mapping_data *b_md = b->data;    INT32 e;    ONERROR err;       /* First some special cases. */    if (!a_md->size || !b_md->size) return allocate_mapping(0);    if (a_md == b_md) return destructive_copy_mapping(a);       /* Copy the second mapping. */ -  res = destructive_copy_mapping(b); +  res = copy_mapping(b);    SET_ONERROR(err, do_free_mapping, res);       /* Remove elements in res that aren't in a. */    NEW_MAPPING_LOOP(b_md) {    size_t h = k->hval % a_md->hashsize;    struct keypair *k2;    for (k2 = a_md->hash[h]; k2; k2 = k2->next) {    if ((k2->hval == k->hval) && is_eq(&k2->ind, &k->ind)) {    break;    }
pike.git/src/mapping.c:2334: Inside #if defined(PIKE_DEBUG)
   Pike_fatal("Mapping from hell detected, attempting to send it back...\n");       if(md->size > 0 && (!md->ind_types || !md->val_types))    Pike_fatal("Mapping type fields are... wrong.\n");       num=0;    NEW_MAPPING_LOOP(md)    {    num++;    +  if (k->ind.type > MAX_TYPE) +  Pike_fatal("Invalid maping keypair index type: %s\n", +  get_name_of_type(k->ind.type));    if(! ( (1 << k->ind.type) & (md->ind_types) ))    Pike_fatal("Mapping indices type field lies.\n");    -  +  if (k->val.type > MAX_TYPE) +  Pike_fatal("Invalid mapping keypair value type: %s\n", +  get_name_of_type(k->val.type));    if(! ( (1 << k->val.type) & (md->val_types) ))    Pike_fatal("Mapping values type field lies.\n");       check_svalue(& k->ind);    check_svalue(& k->val);       /* FIXME add check for k->hval    * beware that hash_svalue may be threaded and locking    * is required!!    */