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.192 2007/10/04 13:03:37 grubba Exp $ + || $Id: mapping.c,v 1.193 2008/01/05 17:58:54 nilsson 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"
pike.git/src/mapping.c:110:    *prev_ = k; \    } \    } while(0)   #endif /* !PIKE_MAPPING_KEYPAIR_LOOP */      #ifdef PIKE_DEBUG      /** This function checks that the type field isn't lacking any bits.    * It is used for debugging purposes only.    */ - static void check_mapping_type_fields(struct mapping *m) + static void check_mapping_type_fields(const struct mapping *m)   {    INT32 e; -  struct keypair *k=0; -  struct mapping_data *md; +  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)    {    val_types |= 1 << k->val.type;    ind_types |= 1 << k->ind.type;    }
pike.git/src/mapping.c:270:    free((char *) md);    GC_FREE_BLOCK(md);   }      PMOD_EXPORT void do_free_mapping(struct mapping *m)   {    if (m)    free_mapping(m);   }    - /** This function is used to rehash a mapping without loosing the internal + /* This function is used to rehash a mapping without loosing the internal    * order in each hash chain. This is to prevent mappings from becoming    * inefficient just after being rehashed.    */   static void mapping_rehash_backwards_evil(struct mapping_data *md,    struct keypair *from)   {    unsigned INT32 h;    struct keypair *k, *prev = NULL, *next;       if(!(k = from)) return;
pike.git/src/mapping.c:805:    const struct svalue *key,    const struct svalue *val)   {    low_mapping_insert(m,key,val,1);   }      /* Inline the above in this file. */   #define mapping_insert(M, KEY, VAL) low_mapping_insert ((M), (KEY), (VAL), 1)      PMOD_EXPORT union anything *mapping_get_item_ptr(struct mapping *m, -  struct svalue *key, +  const struct svalue *key,    TYPE_T t)   {    unsigned INT32 h, h2;    struct keypair *k, **prev;    struct mapping_data *md,*omd;      #ifdef PIKE_DEBUG    if(m->data->refs <=0)    Pike_fatal("Zero refs in mapping->data\n");   
pike.git/src/mapping.c:921:   #endif      #ifdef PIKE_DEBUG    if(d_flag > 1) check_mapping_type_fields(m);   #endif       return & ( k->val.u );   }      PMOD_EXPORT void map_delete_no_free(struct mapping *m, -  struct svalue *key, +  const struct svalue *key,    struct svalue *to)   {    unsigned INT32 h,h2;    struct keypair *k, **prev;    struct mapping_data *md,*omd;      #ifdef PIKE_DEBUG    if(m->data->refs <=0)    Pike_fatal("Zero refs in mapping->data\n");    if(d_flag>1) check_mapping(m);
pike.git/src/mapping.c:1112:    struct pike_string *p)   {    struct svalue tmp;    tmp.type=T_STRING;    tmp.u.string=p;    return low_mapping_lookup(m, &tmp);   }      PMOD_EXPORT void mapping_string_insert(struct mapping *m,    struct pike_string *p, -  struct svalue *val) +  const struct svalue *val)   {    struct svalue tmp;    tmp.type=T_STRING;    tmp.u.string=p;    mapping_insert(m, &tmp, val);   }      PMOD_EXPORT void mapping_string_insert_string(struct mapping *m,    struct pike_string *p,    struct pike_string *val)
pike.git/src/mapping.c:1141:    const char *p)   {    struct pike_string *tmp;    if((tmp=findstring(p)))    return low_mapping_string_lookup(m,tmp);    return 0;   }      /* Lookup in a mapping of mappings */   PMOD_EXPORT struct svalue *mapping_mapping_lookup(struct mapping *m, -  struct svalue *key1, -  struct svalue *key2, +  const struct svalue *key1, +  const struct svalue *key2,    int create)   {    struct svalue tmp;    struct mapping *m2;    struct svalue *s=low_mapping_lookup(m, key1);    debug_malloc_touch(m);      #ifdef PIKE_DEBUG    if(m->data->refs <=0)    Pike_fatal("Zero refs in mapping->data\n");
pike.git/src/mapping.c:1201:    k1.u.string=key1;    k2.type=T_STRING;    k2.u.string=key2;    return mapping_mapping_lookup(m,&k1,&k2,create);   }            PMOD_EXPORT void mapping_index_no_free(struct svalue *dest,    struct mapping *m, -  struct svalue *key) +  const struct svalue *key)   {    struct svalue *p;       if(!IS_DESTRUCTED (key) && (p=low_mapping_lookup(m,key)))    {    if(p->type==T_INT)    p->subtype=NUMBER_NUMBER;       assign_svalue_no_free(dest, p);    }else{
pike.git/src/mapping.c:2113:    }    md->valrefs--;    free_mapping_data(md);       return ret;   }         PMOD_EXPORT void mapping_search_no_free(struct svalue *to,    struct mapping *m, -  struct svalue *look_for, -  struct svalue *key /* start */) +  const struct svalue *look_for, +  const struct svalue *key /* start */)   {    struct mapping_data *md, *omd;      #ifdef PIKE_DEBUG    if(m->data->refs <=0)    Pike_fatal("Zero refs in mapping->data\n");   #endif    md=m->data;       if(md->size)
pike.git/src/mapping.c:2188:    }       to->type=T_INT;    to->subtype=NUMBER_UNDEFINED;    to->u.integer=0;   }         #ifdef PIKE_DEBUG    - void check_mapping(struct mapping *m) + void check_mapping(const struct mapping *m)   {    int e,num;    struct keypair *k; -  struct mapping_data *md; +  const struct mapping_data *md;       static int in_check_mapping;    if(in_check_mapping) return;    in_check_mapping=1;       md=m->data;       if(m->refs <=0)    Pike_fatal("Mapping has zero refs.\n");