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.183 2004/09/18 20:50:52 nilsson Exp $ + || $Id: mapping.c,v 1.184 2005/09/10 02:15:45 grendel 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:103:    Pike_fatal("Node to move not found!\n"); \    } \    ); \    } \    *prev_ = k; \    } \    } while(0)   #endif /* !PIKE_MAPPING_KEYPAIR_LOOP */      #ifdef PIKE_DEBUG - /* This function checks that the type field isn't lacking any bits. +  + /** 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)   {    INT32 e;    struct keypair *k=0,**prev;    struct mapping_data *md;    TYPE_FIELD ind_types, val_types;       ind_types=val_types=0;
pike.git/src/mapping.c:139:      static struct mapping_data empty_data =    { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0, 0, 0,{0}};   static struct mapping_data weak_ind_empty_data =    { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0, MAPPING_WEAK_INDICES, 0,{0}};   static struct mapping_data weak_val_empty_data =    { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0, MAPPING_WEAK_VALUES, 0,{0}};   static struct mapping_data weak_both_empty_data =    { PIKE_CONSTANT_MEMOBJ_INIT(1), 1, 0,0,0,0,0,0, MAPPING_WEAK, 0,{0}};    - /* This function allocates the hash table and svalue space for a mapping + /** This function allocates the hash table and svalue space for a mapping    * struct. The size is the max number of indices that can fit in the    * allocated space.    */   static void init_mapping(struct mapping *m,    INT32 size,    INT16 flags)   {    struct mapping_data *md;    ptrdiff_t e;    INT32 hashsize;
pike.git/src/mapping.c:205:    default: md = &weak_both_empty_data; break;    }    }    add_ref(md);    m->data=md;   #ifdef MAPPING_SIZE_DEBUG    m->debug_size = md->size;   #endif   }    - /* This function allocates an empty mapping with initial room + /** This function allocates an empty mapping with initial room    * for 'size' values. -  +  * +  * @param size initial number of values +  * @return the newly allocated mapping +  * @see do_free_mapping +  * @see free_mapping    */   PMOD_EXPORT struct mapping *debug_allocate_mapping(int size)   {    struct mapping *m;       m=alloc_mapping();       GC_ALLOC(m);       INITIALIZE_PROT(m);
pike.git/src/mapping.c:257:    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;       if(!from) return;
pike.git/src/mapping.c:333:    h%=md->hashsize;    k->next=md->hash[h];    md->hash[h]=k;       /* update */    md->ind_types |= 1<< (k->ind.type);    md->val_types |= 1<< (k->val.type);    md->size++;   }    - /* This function re-allocates a mapping. It adjusts the max no. of + /** This function re-allocates a mapping. It adjusts the max no. of    * values can be fitted into the mapping. It takes a bit of time to    * run, but is used seldom enough not to degrade preformance significantly. -  +  * +  * @param m the mapping to be rehashed +  * @param new_size new mappingsize +  * @return the rehashed mapping    */   static struct mapping *rehash(struct mapping *m, int new_size)   {    struct mapping_data *md, *new_md;   #ifdef PIKE_DEBUG    INT32 tmp=m->data->size;   #endif    INT32 e;       md=m->data;
pike.git/src/mapping.c:577:    md=m->data; \    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 + /** This function brings the type fields in the mapping up to speed. +  * It should be used only when the type fields MUST be correct, which is not    * very often.    */   PMOD_EXPORT void mapping_fix_type_field(struct mapping *m)   {    INT32 e;    struct keypair *k;    TYPE_FIELD ind_types, val_types;       val_types = ind_types = 0;   
pike.git/src/mapping.c:631: Inside #if defined(PIKE_DEBUG)
   else    {    debug_malloc_touch(m);    debug_malloc_touch(md);    }   #endif    md->flags = flags;   }       - /* This function inserts key:val into the mapping m. + /** This function inserts key:val into the mapping m.    * Same as doing m[key]=val; in pike.    * -  * overwrite: -  * 0: Do not replace the value if the entry exists. -  * 1: Replace the value if the entry exists. -  * 2: Replace both the index and the value if the entry exists. +  * @param overwrite how to deal with existing values@n +  * @b 0: Do not replace the value if the entry exists.@n +  * @b 1: Replace the value if the entry exists.@n +  * @b 2: Replace both the index and the value if the entry exists.    */   PMOD_EXPORT void low_mapping_insert(struct mapping *m,    const struct svalue *key,    const struct svalue *val,    int overwrite)   {    unsigned INT32 h,h2;    struct keypair *k, **prev;    struct mapping_data *md, *omd;