pike.git / src / mapping.c

version» Context lines:

pike.git/src/mapping.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: mapping.c,v 1.136 2001/09/06 21:22:00 hubbe Exp $"); + RCSID("$Id: mapping.c,v 1.137 2001/09/24 14:44:47 grubba Exp $");   #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 "dynamic_buffer.h"   #include "interpret.h"
pike.git/src/mapping.c:40:   }while(0)         #define MAPPING_DATA_SIZE(HSIZE, KEYPAIRS) \    (ptrdiff_t)( MD_KEYPAIRS(0, HSIZE) + KEYPAIRS )            #undef EXIT_BLOCK   #define EXIT_BLOCK(m) do{ \ -  INT32 e; \ +    DO_IF_DEBUG( \    if(m->refs) \    fatal("really free mapping on mapping with nonzero refs.\n"); \   ) \    \    FREE_PROT(m); \    \    unlink_mapping_data(m->data); \    \    DOUBLEUNLINK(first_mapping, m); \
pike.git/src/mapping.c:146:      /* 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; -  char *tmp; +     ptrdiff_t e;    INT32 hashsize;       debug_malloc_touch(m);   #ifdef PIKE_DEBUG    if (Pike_in_gc > GC_PASS_PREPARE && Pike_in_gc < GC_PASS_ZAP_WEAK)    fatal("Can't allocate a new mapping_data inside gc.\n");    if(size < 0) fatal("init_mapping with negative value.\n");   #endif    if(size)
pike.git/src/mapping.c:262:   }      /* 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 *tmp; +     struct keypair *k;       if(!from) return;    mapping_rehash_backwards_evil(md,from->next);       /* unlink */    k=md->free_list;   #ifndef PIKE_MAPPING_KEYPAIR_LOOP   #ifdef PIKE_DEBUG    if(!k) fatal("Error in rehash: not enough keypairs.\n");
pike.git/src/mapping.c:298:    /* update */    md->ind_types |= 1<< (k->ind.type);    md->val_types |= 1<< (k->val.type);    md->size++;   }      static void mapping_rehash_backwards_good(struct mapping_data *md,    struct keypair *from)   {    unsigned INT32 h; -  struct keypair *tmp; +     struct keypair *k;       if(!from) return;    mapping_rehash_backwards_good(md,from->next);       /* unlink */    k=md->free_list;   #ifndef PIKE_MAPPING_KEYPAIR_LOOP   #ifdef PIKE_DEBUG    if(!k) fatal("Error in rehash: not enough keypairs.\n");
pike.git/src/mapping.c:1345:    n->data->valrefs++;    n->data->hardlinks++;    debug_malloc_touch(n->data);    return n;   }      #endif      PMOD_EXPORT struct mapping *merge_mappings(struct mapping *a, struct mapping *b, INT32 op)   { -  ONERROR r1,r2,r3,r4,r5; +  ONERROR r1,r2,r3,r4;    struct array *ai, *av;    struct array *bi, *bv;    struct array *ci, *cv;    INT32 *zipper;    struct mapping *m;      #ifdef PIKE_DEBUG    if(a->data->refs <=0)    fatal("Zero refs in mapping->data\n");    if(b->data->refs <=0)
pike.git/src/mapping.c:1627:    return eq;   }      void describe_mapping(struct mapping *m,struct processing *p,int indent)   {    struct processing doing;    struct array *a;    JMP_BUF catch;    ONERROR err;    INT32 e,d; -  struct keypair *k; +     char buf[40];      #ifdef PIKE_DEBUG    if(m->data->refs <=0)    fatal("Zero refs in mapping->data\n");   #endif       if(! m->data->size)    {    my_strcat("([ ])");
pike.git/src/mapping.c:1717:    for(e=2; e<indent; e++) my_putchar(' ');    my_strcat("])");    }       UNSET_ONERROR(err);    free_array(a);   }      node *make_node_from_mapping(struct mapping *m)   { -  struct keypair *k; -  INT32 e; -  +    #ifdef PIKE_DEBUG    if(m->data->refs <=0)    fatal("Zero refs in mapping->data\n");   #endif       mapping_fix_type_field(m);       if((m->data->ind_types | m->data->val_types) & (BIT_FUNCTION | BIT_OBJECT))    {    struct array *ind, *val;
pike.git/src/mapping.c:1767:    *! Groups the arguments together two and two in key-index pairs and    *! creates a mapping of those pairs. Generally, the mapping literal    *! syntax is handier: @code{([ key1:val1, key2:val2, ... ])@}    *!    *! @seealso    *! @[sizeof()], @[mappingp()], @[mkmapping()]    */   PMOD_EXPORT void f_aggregate_mapping(INT32 args)   {    INT32 e; -  struct keypair *k; +     struct mapping *m;       if(args & 1)    Pike_error("Uneven number of arguments to aggregate_mapping.\n");       m=allocate_mapping(MAP_SLOTS(args / 2));       for(e=-args;e<0;e+=2) mapping_insert(m, sp+e, sp+e+1);    pop_n_elems(args);   #ifdef PIKE_DEBUG