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.110 2000/11/01 23:30:36 grubba Exp $"); + RCSID("$Id: mapping.c,v 1.111 2000/11/08 20:03:45 hubbe Exp $");   #include "main.h"   #include "object.h"   #include "mapping.h"   #include "svalue.h"   #include "array.h"   #include "pike_macros.h"   #include "error.h"   #include "pike_memory.h"   #include "dynamic_buffer.h"   #include "interpret.h"
pike.git/src/mapping.c:1314:    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;    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)    fatal("Zero refs in mapping->data\n");   #endif       ai=mapping_indices(a); -  +  SET_ONERROR(r1,do_free_array,ai); +     av=mapping_values(a); -  +  SET_ONERROR(r2,do_free_array,av); +     if(ai->size > 1)    {    zipper=get_set_order(ai);    order_array(ai, zipper);    order_array(av, zipper);    free((char *)zipper);    }       bi=mapping_indices(b); -  +  SET_ONERROR(r3,do_free_array,bi); +     bv=mapping_values(b); -  +  SET_ONERROR(r4,do_free_array,bv); +     if(bi->size > 1)    {    zipper=get_set_order(bi);    order_array(bi, zipper);    order_array(bv, zipper);    free((char *)zipper);    }       zipper=merge(ai,bi,op);       ci=array_zip(ai,bi,zipper); -  free_array(ai); -  free_array(bi); +     -  +  UNSET_ONERROR(r4); free_array(bi); +  UNSET_ONERROR(r3); free_array(ai); +     cv=array_zip(av,bv,zipper); -  free_array(av); -  free_array(bv); +     -  +  UNSET_ONERROR(r2); free_array(bv); +  UNSET_ONERROR(r1); free_array(av); +     free((char *)zipper);       m=mkmapping(ci, cv);    free_array(ci);    free_array(cv);       return m;   }      PMOD_EXPORT struct mapping *merge_mapping_array_ordered(struct mapping *a,    struct array *b, INT32 op)   { -  +  ONERROR r1,r2;    struct array *ai, *av;    struct array *ci = NULL, *cv = NULL;    INT32 *zipper = NULL;    struct mapping *m;       ai=mapping_indices(a); -  +  SET_ONERROR(r1,do_free_array,ai);    av=mapping_values(a); -  +  SET_ONERROR(r2,do_free_array,av);    if(ai->size > 1)    {    zipper=get_set_order(ai);    order_array(ai, zipper);    order_array(av, zipper);    free((char *)zipper);    }       switch (op) /* no elements from »b» may be selected */    {
pike.git/src/mapping.c:1400:    break;    case PIKE_ARRAY_OP_SUB:    zipper=merge(ai,b,op);    ci=array_zip(ai,b,zipper); /* b must not be used */    cv=array_zip(av,b,zipper); /* b must not be used */    break;    default:    fatal("merge_mapping_array on other than AND or SUB\n");    }    -  free_array(ai); -  free_array(av); +  UNSET_ONERROR(r2); free_array(av); +  UNSET_ONERROR(r1); free_array(ai);       free((char *)zipper);       m=mkmapping(ci, cv);    free_array(ci);    free_array(cv);       return m;   }      PMOD_EXPORT struct mapping *merge_mapping_array_unordered(struct mapping *a,    struct array *b, INT32 op)   { -  +  ONERROR r1;    struct array *b_temp;    INT32 *zipper;    struct mapping *m;       if (b->size>1)    {    zipper=get_set_order(b);    b_temp=reorder_and_copy_array(b,zipper); -  +  SET_ONERROR(r1,do_free_array,b_temp);    m=merge_mapping_array_ordered(a,b_temp,op); -  free_array(b_temp); +  UNSET_ONERROR(r1); free_array(b_temp);    }    else    m=merge_mapping_array_ordered(a,b,op);       return m;   }      PMOD_EXPORT struct mapping *add_mappings(struct svalue *argp, INT32 args)   {    INT32 e,d;