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.210 2008/06/29 08:58:30 grubba Exp $ + || $Id: mapping.c,v 1.211 2008/06/29 15:05:16 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"
pike.git/src/mapping.c:1533:    /* First some special cases. */    if (!a_md->size) return destructive_copy_mapping(b);    if (!b_md->size) return destructive_copy_mapping(a);    if (a_md == b_md) return destructive_copy_mapping(a);       if (a_md->size <= b_md->size) {    /* Copy the second mapping. */    res = destructive_copy_mapping(b);    SET_ONERROR(err, do_free_mapping, res);    +  if (!b_md->hashsize) { +  Pike_fatal("Invalid hashsize.\n"); +  } +     /* Add elements in a that aren't in b. */    NEW_MAPPING_LOOP(a_md) {    size_t h = k->hval % b_md->hashsize;    struct keypair *k2;    for (k2 = b_md->hash[h]; k2; k2 = k2->next) {    if ((k2->hval == k->hval) && is_eq(&k2->ind, &k->ind)) {    break;    }    }    if (!k2) {    mapping_insert(res, &k->ind, &k->val); -  +  b_md = b->data;    }    }    UNSET_ONERROR(err);    } else {    /* Copy the first mapping. */    res = destructive_copy_mapping(a);    SET_ONERROR(err, do_free_mapping, res);       /* Add all elements in b. */    NEW_MAPPING_LOOP(b_md) {
pike.git/src/mapping.c:1603:    for (k2 = b_md->hash[h]; k2; k2 = k2->next) {    if ((k2->hval == k->hval) && is_eq(&k2->ind, &k->ind)) {    break;    }    }    if (!k2) {    mapping_insert(res, &k->ind, &k->val);    } else {    map_delete(res, &k2->ind);    } +  b_md = b->data;    }    UNSET_ONERROR(err);    return res;   }      /* NOTE: May perform destructive operations on either of the arguments    * if it has only a single reference.    */   PMOD_EXPORT struct mapping *merge_mappings(struct mapping *a, struct mapping *b, INT32 op)   {