diff --git a/src/OCPikeInterpreter.m b/src/OCPikeInterpreter.m index 6133b901b52e34f75bce3607c201620f01786455..74b64ce27d3672a249ade25011723d3c373963fe 100644 --- a/src/OCPikeInterpreter.m +++ b/src/OCPikeInterpreter.m @@ -114,9 +114,8 @@ static void set_default_master(void) dynbuf_string s; struct svalue t; - *(Pike_sp++) = throw_value; - dmalloc_touch_svalue(Pike_sp-1); - throw_value.type=T_INT; + move_svalue (Pike_sp++, &throw_value); + mark_free_svalue (&throw_value); err = (struct generic_error_struct *) get_storage (Pike_sp[-1].u.object, generic_error_program); diff --git a/src/apply_low.h b/src/apply_low.h index 84cf2cc013cda20085d1eeec0376c57bfe628bfa..5fd853c7f2406b43a40c7143f28db2c4a09eb091 100644 --- a/src/apply_low.h +++ b/src/apply_low.h @@ -2,7 +2,7 @@ || 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: apply_low.h,v 1.31 2007/12/31 12:38:52 grubba Exp $ +|| $Id: apply_low.h,v 1.32 2008/01/26 22:34:17 mast Exp $ */ { @@ -254,12 +254,11 @@ dmalloc_touch_svalue(Pike_sp-i); } } -#endif /* DEBUG_MALLOC */ - Pike_sp[-args-1].type=T_INT; +#endif /* DEBUG_MALLOC */ }else{ free_svalue(Pike_sp-args-1); - Pike_sp[-args-1].type=T_INT; } + mark_free_svalue (Pike_sp - args - 1); low_object_index_no_free(Pike_sp-args-1,o,fun); /* No profiling code for calling variables - Hubbe */ diff --git a/src/array.c b/src/array.c index e7465e09381ba832aa6fb05367f7e72d19ca0154..e6d1172adbcce1c102d033d8468035a678796efc 100644 --- a/src/array.c +++ b/src/array.c @@ -2,7 +2,7 @@ || 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: array.c,v 1.197 2007/12/24 15:33:43 grubba Exp $ +|| $Id: array.c,v 1.198 2008/01/26 22:34:17 mast Exp $ */ #include "global.h" @@ -408,11 +408,7 @@ PMOD_EXPORT struct array *array_insert(struct array *v,struct svalue *s,INT32 in (char *)(ITEM(v)+index), (v->size-index) * sizeof(struct svalue)); } - ITEM(v)[index].type=T_INT; -#ifdef __CHECKER__ - ITEM(v)[index].subtype=0; - ITEM(v)[index].u.refs=0; -#endif + assert_free_svalue (ITEM(v) + index); v->size++; }else{ struct array *ret; @@ -423,17 +419,13 @@ PMOD_EXPORT struct array *array_insert(struct array *v,struct svalue *s,INT32 in MEMCPY(ITEM(ret), ITEM(v), sizeof(struct svalue) * index); MEMCPY(ITEM(ret)+index+1, ITEM(v)+index, sizeof(struct svalue) * (v->size-index)); - ITEM(ret)[index].type=T_INT; -#ifdef __CHECKER__ - ITEM(ret)[index].subtype=0; - ITEM(ret)[index].u.refs=0; -#endif + assert_free_svalue (ITEM(ret) + index); v->size=0; free_array(v); v=ret; } - array_set_index(v,index,s); + array_set_index_no_free (v,index,s); return v; } @@ -1605,6 +1597,7 @@ PMOD_EXPORT struct array *add_arrays(struct svalue *argp, INT32 args) if ((v->item - v->real_item) >= tmp) { debug_malloc_touch(v); argp[e].type=T_INT; + argp[e].subtype = NUMBER_NUMBER; for(tmp=e-1;tmp>=0;tmp--) { debug_malloc_touch(argp[tmp].u.array); @@ -1645,6 +1638,7 @@ PMOD_EXPORT struct array *add_arrays(struct svalue *argp, INT32 args) if (v2) { debug_malloc_touch(v2); argp[e2].type=T_INT; + argp[e2].subtype = NUMBER_NUMBER; MEMMOVE((char *)(ITEM(v2)+tmp2), (char *)ITEM(v2), v2->size * sizeof(struct svalue)); v2->item += tmp2; @@ -1683,6 +1677,7 @@ PMOD_EXPORT struct array *add_arrays(struct svalue *argp, INT32 args) e=argp[0].u.array->size; v=resize_array(argp[0].u.array, size); argp[0].type=T_INT; + argp[0].subtype = NUMBER_NUMBER; size=e; e=1; }else{ diff --git a/src/array.h b/src/array.h index 049e5a76d2267e5ab5ee4093a0214c8242cbc514..34e1b3e86ddca354eb6248b6d505bbf351b23cc4 100644 --- a/src/array.h +++ b/src/array.h @@ -2,7 +2,7 @@ || 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: array.h,v 1.70 2007/12/17 18:02:59 grubba Exp $ +|| $Id: array.h,v 1.71 2008/01/26 22:34:17 mast Exp $ */ #ifndef ARRAY_H @@ -283,11 +283,10 @@ PMOD_EXPORT struct array *implode_array(struct array *a, struct array *b); * @param I the index of the array to set * @param S the svalue to set */ -#define array_set_index(V,I,S) do { \ +#define array_set_index_no_free(V,I,S) do { \ struct array *v_=(V); \ INT32 index_=(I); \ struct svalue *s_=(S); \ - struct svalue tmp_; \ \ DO_IF_DEBUG( \ if(index_<0 || index_>v_->size) \ @@ -295,11 +294,24 @@ PMOD_EXPORT struct array *implode_array(struct array *a, struct array *b); ) \ \ check_destructed(s_); \ - tmp_=ITEM(v_)[index_]; \ \ v_->type_field |= 1 << s_->type; \ assign_svalue_no_free( ITEM(v_) + index_, s_); \ - free_svalue(&tmp_); \ +}while(0) +#define array_set_index(V,I,S) do { \ + struct array *v_=(V); \ + INT32 index_=(I); \ + struct svalue *s_=(S); \ + \ + DO_IF_DEBUG( \ + if(index_<0 || index_>v_->size) \ + Pike_fatal("Illegal index in low level array set routine.\n"); \ + ) \ + \ + check_destructed(s_); \ + \ + v_->type_field |= 1 << s_->type; \ + assign_svalue( ITEM(v_) + index_, s_); \ }while(0) #define array_fix_unfinished_type_field(A) do { \ diff --git a/src/bignum.c b/src/bignum.c index 9c066ec37fe6ce0679f2b956b8a64ae257d3347f..ccba3d4a3060b1ac86c2dc47a4c926034437c218 100644 --- a/src/bignum.c +++ b/src/bignum.c @@ -2,7 +2,7 @@ || 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: bignum.c,v 1.41 2004/12/30 13:23:20 grubba Exp $ +|| $Id: bignum.c,v 1.42 2008/01/26 22:34:17 mast Exp $ */ #include "global.h" @@ -18,7 +18,7 @@ #define sp Pike_sp PMOD_EXPORT struct svalue auto_bignum_program = { - T_INT, 0, + PIKE_T_FREE, 0, #ifdef HAVE_UNION_INIT {0}, /* Only to avoid warnings. */ #endif @@ -31,7 +31,7 @@ PMOD_EXPORT struct program *get_auto_bignum_program(void) PMOD_EXPORT struct program *get_auto_bignum_program_or_zero(void) { - if (auto_bignum_program.type == T_INT) + if (auto_bignum_program.type == PIKE_T_FREE) return 0; return program_from_function(&auto_bignum_program); } @@ -39,7 +39,7 @@ PMOD_EXPORT struct program *get_auto_bignum_program_or_zero(void) void exit_auto_bignum(void) { free_svalue(&auto_bignum_program); - auto_bignum_program.type=T_INT; + mark_free_svalue (&auto_bignum_program); } PMOD_EXPORT void convert_stack_top_to_bignum(void) diff --git a/src/builtin.cmod b/src/builtin.cmod index e11d24e20d58847a03278f18ded52bbd1088f5b1..babc8a0ac4cf131569235842d66c0ab25313f130 100644 --- a/src/builtin.cmod +++ b/src/builtin.cmod @@ -2,7 +2,7 @@ || 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: builtin.cmod,v 1.192 2007/08/06 08:09:36 nilsson Exp $ +|| $Id: builtin.cmod,v 1.193 2008/01/26 22:34:17 mast Exp $ */ #include "global.h" @@ -570,6 +570,7 @@ PIKEFUN mapping(string:mixed) gc_parameters (void|mapping(string:mixed) params) } }, { get.type = T_INT; + get.subtype = NUMBER_NUMBER; get.u.integer = gc_enabled; }); HANDLE_FLOAT_FACTOR ("garbage_ratio_low", gc_garbage_ratio_low); @@ -1895,7 +1896,7 @@ PIKECLASS Buffer if (shift == Pike_sp[-args].u.string->size_shift && init_string_builder_with_string (&str->str, Pike_sp[-args].u.string)) { - Pike_sp[-args].type = T_INT; + mark_free_svalue (Pike_sp - args); if (sum > str->str.s->len) string_build_mkspace (&str->str, sum - str->str.s->len, shift); init_from_arg0 = 1; diff --git a/src/builtin_functions.c b/src/builtin_functions.c index bf76b95a39c01706c212ef7471a8274e0b3380b5..4403aa161edae438fea8160be188389f7ae51de6 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -2,7 +2,7 @@ || 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: builtin_functions.c,v 1.649 2008/01/23 19:52:49 grubba Exp $ +|| $Id: builtin_functions.c,v 1.650 2008/01/26 22:34:17 mast Exp $ */ #include "global.h" @@ -3942,9 +3942,10 @@ node *optimize_replace(node *n) struct svalue *save_sp = Pike_sp; JMP_BUF tmp; if (SETJMP(tmp)) { - struct svalue thrown = throw_value; + struct svalue thrown; struct pike_string *s; - throw_value.type = T_INT; + move_svalue (&thrown, &throw_value); + mark_free_svalue (&throw_value); pop_n_elems(Pike_sp - save_sp); yywarning("Optimizer failure in replace()."); s = format_exception_for_error_msg (&thrown); @@ -6082,10 +6083,12 @@ static struct array* diff_compare_table(struct array *a,struct array *b,int *u) } else { - pval->u.array=resize_array(pval->u.array,pval->u.array->size+1); - pval->u.array->item[pval->u.array->size-1].type=T_INT; - pval->u.array->item[pval->u.array->size-1].subtype=NUMBER_NUMBER; - pval->u.array->item[pval->u.array->size-1].u.integer=i; + struct array *a = pval->u.array= + resize_array(pval->u.array,pval->u.array->size+1); + struct svalue *s = ITEM(a) + pval->u.array->size-1; + s->type=T_INT; + s->subtype=NUMBER_NUMBER; + s->u.integer=i; } } @@ -7533,6 +7536,10 @@ PMOD_EXPORT void f_object_variablep(INT32 args) /*! @module Array */ +#ifdef HAVE_UNION_INIT +static const struct svalue one = {PIKE_T_INT, NUMBER_NUMBER, {1}}; +#endif + /*! @decl array uniq(array a) *! *! Remove elements that are duplicates. @@ -7552,15 +7559,20 @@ PMOD_EXPORT void f_uniq_array(INT32 args) { struct array *a, *b; struct mapping *m; +#ifndef HAVE_UNION_INIT struct svalue one; +#endif int i, j=0,size=0; get_all_args("uniq", args, "%a", &a); push_mapping(m = allocate_mapping(a->size)); push_array(b = allocate_array(a->size)); +#ifndef HAVE_UNION_INIT one.type = T_INT; + one.subtype = NUMBER_NUMBER; one.u.integer = 1; +#endif for(i =0; i< a->size; i++) { mapping_insert(m, ITEM(a)+i, &one); @@ -7982,8 +7994,8 @@ PMOD_EXPORT void f_map(INT32 args) push_svalue(mysp-3); /* arr */ f_values(1); push_svalue(mysp-2); /* fun */ - *Pike_sp=mysp[-1]; /* extra */ - mysp[-1].type=T_INT; + move_svalue (Pike_sp, mysp-1); /* extra */ + mark_free_svalue (mysp-1); dmalloc_touch_svalue(Pike_sp); push_array_items(Pike_sp->u.array); f_map(splice+2); /* ... arr fun extra -> ... retval */ @@ -7999,7 +8011,7 @@ PMOD_EXPORT void f_map(INT32 args) (multiset)(map(indices(arr),fun,@extra)); */ push_svalue(Pike_sp-args); /* take indices from arr */ free_svalue(Pike_sp-args-1); /* move it to top of stack */ - Pike_sp[-args-1].type=T_INT; + mark_free_svalue (Pike_sp-args-1); f_indices(1); /* call f_indices */ Pike_sp--; dmalloc_touch_svalue(Pike_sp); @@ -8019,7 +8031,7 @@ PMOD_EXPORT void f_map(INT32 args) (string)(map((array)arr,fun,@extra)); */ push_svalue(Pike_sp-args); /* take indices from arr */ free_svalue(Pike_sp-args-1); /* move it to top of stack */ - Pike_sp[-args-1].type=T_INT; + mark_free_svalue (Pike_sp-args-1); o_cast(NULL,T_ARRAY); /* cast the string to an array */ Pike_sp--; dmalloc_touch_svalue(Pike_sp); @@ -8139,7 +8151,7 @@ PMOD_EXPORT void f_map(INT32 args) if (UNSAFE_IS_ZERO (Pike_sp-args+1)) { free_svalue (Pike_sp-args+1); move_svalue (Pike_sp-args+1, Pike_sp-args); - Pike_sp[-args].type = T_INT; + mark_free_svalue (Pike_sp-args); mega_apply (APPLY_STACK, args-1, 0, 0); stack_pop_keep_top(); return; @@ -8400,8 +8412,8 @@ PMOD_EXPORT void f_filter(INT32 args) map(values(arr),fun,@extra)); */ MEMMOVE(Pike_sp-args+2,Pike_sp-args,args*sizeof(*Pike_sp)); Pike_sp+=2; - Pike_sp[-args-2].type=T_INT; - Pike_sp[-args-1].type=T_INT; + mark_free_svalue (Pike_sp-args-2); + mark_free_svalue (Pike_sp-args-1); push_svalue(Pike_sp-args); f_indices(1); @@ -8438,7 +8450,7 @@ PMOD_EXPORT void f_filter(INT32 args) case T_MULTISET: push_svalue(Pike_sp-args); /* take indices from arr */ free_svalue(Pike_sp-args-1); /* move it to top of stack */ - Pike_sp[-args-1].type=T_INT; + mark_free_svalue (Pike_sp-args-1); f_indices(1); /* call f_indices */ Pike_sp--; dmalloc_touch_svalue(Pike_sp); @@ -8456,7 +8468,7 @@ PMOD_EXPORT void f_filter(INT32 args) case T_STRING: push_svalue(Pike_sp-args); /* take indices from arr */ free_svalue(Pike_sp-args-1); /* move it to top of stack */ - Pike_sp[-args-1].type=T_INT; + mark_free_svalue (Pike_sp-args-1); o_cast(NULL,T_ARRAY); /* cast the string to an array */ Pike_sp--; dmalloc_touch_svalue(Pike_sp); diff --git a/src/configure.in b/src/configure.in index 11b4b38fb6c24cc90fbdde6492a70579e978b518..4e6913b62c46ccf20a9bd1c632df968f24be7b8d 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1,4 +1,4 @@ -AC_REVISION("$Id: configure.in,v 1.1037 2008/01/14 22:23:42 grubba Exp $") +AC_REVISION("$Id: configure.in,v 1.1038 2008/01/26 22:34:18 mast Exp $") AC_INIT(interpret.c) AC_CONFIG_HEADER(machine.h) @@ -2353,7 +2353,7 @@ if test "x$PIKE_PATH_TRANSLATE" = "x"; then # MinGW system. cat <<\EOF #!/bin/sh -# Automatically generated by $Id: configure.in,v 1.1037 2008/01/14 22:23:42 grubba Exp $. +# Automatically generated by $Id: configure.in,v 1.1038 2008/01/26 22:34:18 mast Exp $. # MinGW-version. Do NOT edit. posix_name="`cat`" posix_prefix="/" @@ -2391,7 +2391,7 @@ EOF # Native POSIX system. cat <<\EOF #!/bin/sh -# Automatically generated by $Id: configure.in,v 1.1037 2008/01/14 22:23:42 grubba Exp $. +# Automatically generated by $Id: configure.in,v 1.1038 2008/01/26 22:34:18 mast Exp $. # POSIX-version. Do NOT edit. cat EOF @@ -2400,7 +2400,7 @@ else # rntcl-style cat <<\EOF #!/bin/sh -# Automatically generated by $Id: configure.in,v 1.1037 2008/01/14 22:23:42 grubba Exp $. +# Automatically generated by $Id: configure.in,v 1.1038 2008/01/26 22:34:18 mast Exp $. # RNTCL-version. Do NOT edit. sed -e "$PIKE_PATH_TRANSLATE" EOF @@ -2681,8 +2681,6 @@ fi ############################################################################# -AC_DEFINE(POSIX_SOURCE) - AC_MSG_CHECKING(ansi prototype capability) AC_CACHE_VAL(pike_cv_sys_ansi_prototypes, [ diff --git a/src/cpp.c b/src/cpp.c index d9bb639672a771e822d5895bdc6ff024aa0f166a..53a80d89d86a8c3a03a6b9f05c5fc611d49e3998 100644 --- a/src/cpp.c +++ b/src/cpp.c @@ -2,7 +2,7 @@ || 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: cpp.c,v 1.163 2007/10/22 09:49:44 grubba Exp $ +|| $Id: cpp.c,v 1.164 2008/01/26 22:34:19 mast Exp $ */ #include "global.h" @@ -214,7 +214,7 @@ static void cpp_handle_exception(struct cpp *this, { struct svalue thrown; move_svalue (&thrown, &throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); if (cpp_error_fmt) { va_list args; @@ -537,7 +537,7 @@ static int do_safe_index_call(struct cpp *this, struct pike_string *s) if (SETJMP_SP(recovery, 1)) { if (CPP_TEST_COMPAT (this, 7, 4)) { free_svalue (&throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); } else if(this->picky_cpp) { cpp_warning (this, "Error indexing module with %S.", s); @@ -638,7 +638,7 @@ void cpp_func_constant(struct cpp *this, INT32 args) !throw_value.u.string->size_shift) { cpp_error(this, throw_value.u.string->str); free_svalue(&throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); res = 0; } else if(this->picky_cpp) { cpp_warning (this, "Error resolving %S.", str); diff --git a/src/encode.c b/src/encode.c index 201dc665fa482a69e7a8d71dc7310c59deee149d..40769d91dd4a6226a20b37b6b89bd4284b8e03ad 100644 --- a/src/encode.c +++ b/src/encode.c @@ -2,7 +2,7 @@ || 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: encode.c,v 1.249 2008/01/19 17:06:50 grubba Exp $ +|| $Id: encode.c,v 1.250 2008/01/26 22:34:19 mast Exp $ */ #include "global.h" @@ -444,7 +444,7 @@ static void zap_unfinished_program(struct program *p) for(e=0;e<p->num_constants;e++) { free_svalue(& p->constants[e].sval); - p->constants[e].sval.type=T_INT; + mark_free_svalue (&p->constants[e].sval); } for(e=0;e<p->num_inherits;e++) @@ -1847,6 +1847,7 @@ void f_encode_value_canonic(INT32 args) data->encoded=allocate_mapping(128); data->delayed = allocate_array (0); data->counter.type=T_INT; + data->counter.subtype=NUMBER_NUMBER; data->counter.u.integer=COUNTER_START; #ifdef ENCODE_DEBUG @@ -3056,7 +3057,7 @@ static void decode_value2(struct decode_data *data) #include "program_areas.h" for(e=0;e<p->num_constants;e++) - p->constants[e].sval.type=T_INT; + mark_free_svalue (&p->constants[e].sval); debug_malloc_touch(dat); debug_malloc_touch(p); @@ -4457,7 +4458,7 @@ int re_decode(struct decode_data *data, int ignored) JMP_BUF recovery; struct svalue orig_thrown; move_svalue (&orig_thrown, &throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); if (SETJMP (recovery)) { UNSETJMP (recovery); diff --git a/src/error.c b/src/error.c index b1509333a4e878751a3378387c94d6ac3a17181a..5615b08a82cdc2bfecfb477ad3b24748e77d79bb 100644 --- a/src/error.c +++ b/src/error.c @@ -2,7 +2,7 @@ || 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: error.c,v 1.150 2007/07/04 17:35:42 grubba Exp $ +|| $Id: error.c,v 1.151 2008/01/26 22:34:20 mast Exp $ */ #define NO_PIKE_SHORTHAND @@ -196,7 +196,7 @@ PMOD_EXPORT void push_error(const char *description) } PMOD_EXPORT struct svalue throw_value = { - PIKE_T_INT, 0, + PIKE_T_INT, NUMBER_NUMBER, #ifdef HAVE_UNION_INIT {0}, /* Only to avoid warnings. */ #endif @@ -482,7 +482,7 @@ PMOD_EXPORT void exit_on_error(const void *msg) fprintf(stderr,"Attempting to dump raw error: (may fail)\n"); init_buf(&save_buf); move_svalue (&thrown, &throw_value); - throw_value.type = PIKE_T_INT; + mark_free_svalue (&throw_value); describe_svalue(&thrown,0,0); free_svalue (&thrown); s=simple_free_buf(&save_buf); diff --git a/src/interpret.c b/src/interpret.c index 07b6862ee510b6ef379c712dc52ec5b9d4fd0fe6..f1006986fbda7e1446260db38984144368111cc4 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -2,7 +2,7 @@ || 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: interpret.c,v 1.384 2008/01/13 19:08:30 grubba Exp $ +|| $Id: interpret.c,v 1.385 2008/01/26 22:34:20 mast Exp $ */ #include "global.h" @@ -2278,9 +2278,8 @@ PMOD_EXPORT void call_handle_error(void) Pike_interpreter.trace_level = 0; Pike_interpreter.svalue_stack_margin = LOW_SVALUE_STACK_MARGIN; Pike_interpreter.c_stack_margin = LOW_C_STACK_MARGIN; - *(Pike_sp++) = throw_value; - dmalloc_touch_svalue(Pike_sp-1); - throw_value.type=T_INT; + move_svalue (Pike_sp++, &throw_value); + mark_free_svalue (&throw_value); if (get_master()) { /* May return NULL at odd times. */ ONERROR tmp; @@ -2320,7 +2319,7 @@ PMOD_EXPORT void call_handle_error(void) else { free_svalue(&throw_value); - throw_value.type=T_INT; + mark_free_svalue (&throw_value); } } @@ -2413,7 +2412,7 @@ PMOD_EXPORT void safe_apply_low2(struct object *o, int fun, int args, JMP_BUF recovery; free_svalue(& throw_value); - throw_value.type=T_INT; + mark_free_svalue (&throw_value); if(SETJMP_SP(recovery, args)) { if(fun_name) call_handle_error(); @@ -2521,7 +2520,7 @@ PMOD_EXPORT int safe_apply_handler(const char *fun, #endif /* 0 */ free_svalue(& throw_value); - throw_value.type=T_INT; + mark_free_svalue (&throw_value); if (SETJMP_SP(recovery, args)) { ret = 0; @@ -2610,7 +2609,7 @@ PMOD_EXPORT void safe_apply_svalue(struct svalue *s, int args, int handle_errors { JMP_BUF recovery; free_svalue(& throw_value); - throw_value.type=T_INT; + mark_free_svalue (&throw_value); if(SETJMP_SP(recovery, args)) { if(handle_errors) call_handle_error(); diff --git a/src/interpret_functions.h b/src/interpret_functions.h index 2752f3e094fefc89ddd348c00bb3984c7915a8a6..5664f9f26c5d02ddcfb7d4be1aab98007467c578 100644 --- a/src/interpret_functions.h +++ b/src/interpret_functions.h @@ -2,7 +2,7 @@ || 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: interpret_functions.h,v 1.196 2007/12/17 18:01:52 grubba Exp $ +|| $Id: interpret_functions.h,v 1.197 2008/01/26 22:34:20 mast Exp $ */ /* @@ -650,7 +650,7 @@ OPCODE0(F_LTOSVAL2, "ltosval2", I_UPDATE_SP, { dmalloc_touch_svalue(Pike_sp-1); move_svalue (Pike_sp, Pike_sp - 1); - Pike_sp[-1].type = PIKE_T_INT; + mark_free_svalue (Pike_sp - 1); Pike_sp++; lvalue_to_svalue_no_free(Pike_sp-2, Pike_sp-4); /* This is so that foo+=bar (and similar things) will be faster. @@ -678,7 +678,7 @@ OPCODE0(F_LTOSVAL3, "ltosval3", I_UPDATE_SP, { move_svalue (Pike_sp, Pike_sp - 1); move_svalue (Pike_sp - 1, Pike_sp - 2); - Pike_sp[-2].type = PIKE_T_INT; + mark_free_svalue (Pike_sp - 2); Pike_sp++; lvalue_to_svalue_no_free(Pike_sp-3, Pike_sp-5); @@ -722,7 +722,7 @@ OPCODE0(F_LTOSVAL1, "ltosval1", I_UPDATE_SP, { OPCODE0(F_ADD_TO, "+=", I_UPDATE_SP, { ONERROR uwp; move_svalue (Pike_sp, Pike_sp - 1); - Pike_sp[-1].type=PIKE_T_INT; + mark_free_svalue (Pike_sp - 1); Pike_sp++; lvalue_to_svalue_no_free(Pike_sp-2,Pike_sp-4); @@ -791,7 +791,7 @@ OPCODE0(F_ADD_TO, "+=", I_UPDATE_SP, { OPCODE0(F_ADD_TO_AND_POP, "+= and pop", I_UPDATE_SP, { ONERROR uwp; move_svalue (Pike_sp, Pike_sp - 1); - Pike_sp[-1].type=PIKE_T_INT; + mark_free_svalue (Pike_sp - 1); Pike_sp++; lvalue_to_svalue_no_free(Pike_sp-2,Pike_sp-4); @@ -1106,7 +1106,7 @@ OPCODE2_BRANCH(F_BRANCH_IF_NOT_LOCAL_ARROW, "branch if !local->x", 0, { tmp.type=PIKE_T_STRING; tmp.u.string=Pike_fp->context.prog->strings[arg1]; tmp.subtype=1; - Pike_sp->type=PIKE_T_INT; + mark_free_svalue (Pike_sp); Pike_sp++; index_no_free(Pike_sp-1,Pike_fp->locals+arg2, &tmp); print_return_value(); @@ -1378,7 +1378,7 @@ OPCODE0_PTRJUMP(F_CATCH, "catch", I_UPDATE_ALL, { UNSETJMP (cc->recovery); Pike_fp->expendible = cc->save_expendible; move_svalue (Pike_sp++, &throw_value); - throw_value.type=T_INT; + mark_free_svalue (&throw_value); low_destruct_objects_to_destruct(); if (cc->continue_reladdr < 0) @@ -1802,7 +1802,7 @@ OPCODE2(F_LOCAL_LOCAL_INDEX, "local[local]", I_UPDATE_SP, { LOCAL_VAR(struct svalue *s); s = Pike_fp->locals + arg1; if(s->type == PIKE_T_STRING) s->subtype=0; - Pike_sp++->type=PIKE_T_INT; + mark_free_svalue (Pike_sp++); index_no_free(Pike_sp-1,Pike_fp->locals+arg2,s); }); @@ -1833,8 +1833,7 @@ OPCODE2(F_LOCAL_ARROW, "local->x", I_UPDATE_SP, { tmp.type=PIKE_T_STRING; tmp.u.string=Pike_fp->context.prog->strings[arg1]; tmp.subtype=1; - Pike_sp->type=PIKE_T_INT; - Pike_sp++; + mark_free_svalue (Pike_sp++); index_no_free(Pike_sp-1,Pike_fp->locals+arg2, &tmp); print_return_value(); }); diff --git a/src/iterators.cmod b/src/iterators.cmod index b8cb25376b80670dcb67dfab910759a6fff3cffc..2bfbb410b1441f275cb61398939cf6953c2e591c 100644 --- a/src/iterators.cmod +++ b/src/iterators.cmod @@ -2,7 +2,7 @@ || 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: iterators.cmod,v 1.63 2007/11/11 13:19:32 nilsson Exp $ +|| $Id: iterators.cmod,v 1.64 2008/01/26 22:34:20 mast Exp $ */ #include "global.h" @@ -1090,8 +1090,7 @@ PIKECLASS file_line_iterator THIS->current = NULL; THIS->offset = 0; THIS->index = 0; - THIS->feed.type = T_INT; - THIS->feed.u.integer = 0; + mark_free_svalue (&THIS->feed); } EXIT @@ -1105,8 +1104,7 @@ PIKECLASS file_line_iterator THIS->current = NULL; } free_svalue(&THIS->feed); - THIS->feed.type = T_INT; - THIS->feed.u.integer = 0; + assert_free_svalue (&THIS->feed); } @@ -1275,7 +1273,7 @@ PIKECLASS string_split_iterator ssi->buffer = NULL; \ ssi->offset = 0; \ offset = 0; \ - if (ssi->feed.type == T_INT) { \ + if (ssi->feed.type == PIKE_T_FREE) { \ if (!(FLAGS)) { \ copy_shared_string(ssi->current, empty_pike_string); \ ssi->index++; \ @@ -1292,8 +1290,7 @@ PIKECLASS string_split_iterator goto reskip_empty; \ } \ free_svalue(&ssi->feed); \ - ssi->feed.type = T_INT; \ - ssi->feed.u.integer = 0; \ + mark_free_svalue (&ssi); \ pop_stack(); \ if (!(FLAGS)) { \ copy_shared_string(ssi->current, empty_pike_string); \ @@ -1315,7 +1312,7 @@ PIKECLASS string_split_iterator COMPLEX_SCAN_PUSH(ssi, SHIFT, end); \ } \ if ((end == ssi->buffer->len) && \ - (ssi->feed.type != T_INT)) { \ + (ssi->feed.type != PIKE_T_FREE)) { \ apply_svalue(&ssi->feed, 0); \ if ((Pike_sp[-1].type == T_STRING) && \ (Pike_sp[-1].u.string->len)) { \ @@ -1335,8 +1332,7 @@ PIKECLASS string_split_iterator \ /* Make sure we don't call feed() any more. */ \ free_svalue(&ssi->feed); \ - ssi->feed.type = T_INT; \ - ssi->feed.u.integer = 0; \ + mark_free_svalue (&ssi); \ } \ ssi->offset = end+1; \ ssi->current = Pike_sp[-1].u.string; \ @@ -1452,15 +1448,14 @@ PIKECLASS string_split_iterator push_int(THIS->buffer->len); o_range(); } - for (i = 1; THIS->feed.type != T_INT; i++) { + for (i = 1; THIS->feed.type != PIKE_T_FREE; i++) { apply_svalue(&THIS->feed, 0); if ((Pike_sp[-1].type != T_STRING) || (!Pike_sp[-1].u.string->len)) { /* End of stream marker. */ pop_stack(); free_svalue(&THIS->feed); - THIS->feed.type = T_INT; - THIS->feed.u.integer = 0; + mark_free_svalue (&THIS->feed); break; } } @@ -1586,7 +1581,8 @@ PIKECLASS string_split_iterator if (feed) { assign_svalue(&THIS->feed, feed); } else { - /* NB: THIS->feed has already been set to 0 by the init code. */ + /* NB: THIS->feed has already been set to PIKE_T_FREE by the + * init code. */ } } else { THIS->flags = 0; @@ -1606,8 +1602,7 @@ PIKECLASS string_split_iterator THIS->split_set = NULL; THIS->split_set_size = 0; THIS->flags = 0; - THIS->feed.type = T_INT; - THIS->feed.u.integer = 0; + mark_free_svalue (&THIS->feed); } EXIT @@ -1623,8 +1618,7 @@ PIKECLASS string_split_iterator free(THIS->split_set); THIS->split_set = NULL; free_svalue(&THIS->feed); - THIS->feed.type = T_INT; - THIS->feed.u.integer = 0; + mark_free_svalue (&THIS->feed); } OPTIMIZE diff --git a/src/las.c b/src/las.c index 0e6a6162fd5f057da30f004dbc72c1762e63c08c..ae0d02a78c64aca096b6c8324278c434b0d39058 100644 --- a/src/las.c +++ b/src/las.c @@ -2,7 +2,7 @@ || 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: las.c,v 1.402 2008/01/16 19:41:13 grubba Exp $ +|| $Id: las.c,v 1.403 2008/01/26 22:34:21 mast Exp $ */ #include "global.h" @@ -5163,11 +5163,11 @@ ptrdiff_t eval_low(node *n,int print_error) handle_compile_exception("Error evaluating constant."); else { free_svalue(&throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); } else { free_svalue(&throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); /* Assume the node will throw errors at runtime too. */ n->tree_info |= OPT_SIDE_EFFECT; n->node_info |= OPT_SIDE_EFFECT; diff --git a/src/main.c b/src/main.c index 39d99c3dbba686e71203a9f59296a4eefb9ca495..9adb03d50fbb488b606df7dcbeda64694d586956 100644 --- a/src/main.c +++ b/src/main.c @@ -2,7 +2,7 @@ || 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: main.c,v 1.227 2007/05/18 14:00:48 grubba Exp $ +|| $Id: main.c,v 1.228 2008/01/26 22:34:21 mast Exp $ */ #include "global.h" @@ -549,9 +549,8 @@ int main(int argc, char **argv) dynbuf_string s; struct svalue t; - *(Pike_sp++) = throw_value; - dmalloc_touch_svalue(Pike_sp-1); - throw_value.type=T_INT; + move_svalue (Pike_sp++, &throw_value); + mark_free_svalue (&throw_value); err = (struct generic_error_struct *) get_storage (Pike_sp[-1].u.object, generic_error_program); diff --git a/src/mapping.c b/src/mapping.c index 0d428c114325de6231454229d049d0474a3c6329..ecb77002c39f2ae0f555e5eb36c17c475cf3deb0 100644 --- a/src/mapping.c +++ b/src/mapping.c @@ -2,7 +2,7 @@ || 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.194 2008/01/05 18:05:10 nilsson Exp $ +|| $Id: mapping.c,v 1.195 2008/01/26 22:34:21 mast Exp $ */ #include "global.h" @@ -190,12 +190,12 @@ static void init_mapping(struct mapping *m, for(e=1;e<size;e++) { md->free_list[e-1].next = md->free_list + e; - md->free_list[e-1].ind.type=T_INT; - md->free_list[e-1].val.type=T_INT; + mark_free_svalue (&md->free_list[e-1].ind); + mark_free_svalue (&md->free_list[e-1].val); } md->free_list[e-1].next=0; - md->free_list[e-1].ind.type=T_INT; - md->free_list[e-1].val.type=T_INT; + mark_free_svalue (&md->free_list[e-1].ind); + mark_free_svalue (&md->free_list[e-1].val); #endif /* !PIKE_MAPPING_KEYPAIR_LOOP */ md->ind_types = 0; md->val_types = 0; @@ -987,8 +987,8 @@ PMOD_EXPORT void map_delete_no_free(struct mapping *m, FREE_KEYPAIR(md, k); - md->free_list->ind.type=T_INT; - md->free_list->val.type=T_INT; + mark_free_svalue (&md->free_list->ind); + mark_free_svalue (&md->free_list->val); md->size--; #ifdef MAPPING_SIZE_DEBUG @@ -1048,8 +1048,8 @@ PMOD_EXPORT void check_mapping_for_destruct(struct mapping *m) free_svalue(& k->ind); free_svalue(& k->val); FREE_KEYPAIR(md, k); - md->free_list->ind.type = T_INT; - md->free_list->val.type = T_INT; + mark_free_svalue (&md->free_list->ind); + mark_free_svalue (&md->free_list->val); md->size--; #ifdef MAPPING_SIZE_DEBUG if(m->data ==md) @@ -1214,8 +1214,10 @@ PMOD_EXPORT void mapping_index_no_free(struct svalue *dest, if(!IS_DESTRUCTED (key) && (p=low_mapping_lookup(m,key))) { +#if 0 if(p->type==T_INT) p->subtype=NUMBER_NUMBER; +#endif assign_svalue_no_free(dest, p); }else{ @@ -1946,7 +1948,7 @@ void describe_mapping(struct mapping *m,struct processing *p,int indent) Pike_interpreter.trace_level = 0; if(SETJMP(catch)) { free_svalue(&throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); } else sort_array_destructively(a); @@ -2364,8 +2366,8 @@ void check_all_mappings(void) } \ (*prev_)->next = k->next; \ FREE_KEYPAIR(MD, k); \ - MD->free_list->ind.type = T_INT; \ - MD->free_list->val.type = T_INT; \ + mark_free_svalue (&MD->free_list->ind); \ + mark_free_svalue (&MD->free_list->val); \ MD->size--; \ DO_IF_MAPPING_SIZE_DEBUG( \ if(M->data ==MD) \ @@ -2397,8 +2399,8 @@ void check_all_mappings(void) { \ *prev=k->next; \ FREE_KEYPAIR(MD, k); \ - MD->free_list->ind.type = T_INT; \ - MD->free_list->val.type = T_INT; \ + mark_free_svalue (&MD->free_list->ind); \ + mark_free_svalue (&MD->free_list->val); \ MD->size--; \ DO_IF_MAPPING_SIZE_DEBUG( \ if(M->data ==MD) \ diff --git a/src/module.c b/src/module.c index ebec775d3b80245fbbcc3ffaf80453a78395c319..13eaf512f583d0f9dc7d1c8a229c7498ffba6dc8 100644 --- a/src/module.c +++ b/src/module.c @@ -2,7 +2,7 @@ || 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: module.c,v 1.46 2007/10/06 13:45:22 grubba Exp $ +|| $Id: module.c,v 1.47 2008/01/26 22:34:21 mast Exp $ */ #include "global.h" @@ -154,7 +154,7 @@ static void exit_builtin_modules(void) exit_pike_security(); free_svalue(& throw_value); - throw_value.type=T_INT; + mark_free_svalue (&throw_value); do_gc(NULL, 1); diff --git a/src/modules/Gmp/mpz_glue.c b/src/modules/Gmp/mpz_glue.c index 8671437d6e9b3d15f30b4a3f8801c1c4cc89d0be..6293a338539046934c306683478d84ebab7e8a3b 100644 --- a/src/modules/Gmp/mpz_glue.c +++ b/src/modules/Gmp/mpz_glue.c @@ -2,7 +2,7 @@ || 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: mpz_glue.c,v 1.169 2007/12/27 17:13:37 grubba Exp $ +|| $Id: mpz_glue.c,v 1.170 2008/01/26 22:34:25 mast Exp $ */ #include "global.h" @@ -1063,7 +1063,7 @@ static void name(INT32 args) \ case T_STRING: \ MEMMOVE(sp-args+1, sp-args, sizeof(struct svalue)*args); \ sp++; args++; \ - sp[-args].type=T_INT; \ + sp[-args].type=PIKE_T_FREE; \ sp[-args].u.string=low_get_mpz_digits(THIS, 10); \ sp[-args].type=T_STRING; \ f_add(args); \ @@ -1154,7 +1154,7 @@ static void PIKE_CONCAT(name,_eq)(INT32 args) \ case T_STRING: \ MEMMOVE(sp-args+1, sp-args, sizeof(struct svalue)*args); \ sp++; args++; \ - sp[-args].type=T_INT; \ + sp[-args].type=PIKE_T_FREE; \ sp[-args].u.string=low_get_mpz_digits(THIS, 10); \ sp[-args].type=T_STRING; \ f_add(args); \ @@ -2081,7 +2081,7 @@ PIKE_MODULE_EXIT { extern struct svalue auto_bignum_program; free_svalue(&auto_bignum_program); - auto_bignum_program.type=T_INT; + auto_bignum_program.type=PIKE_T_FREE; if(bignum_program) { free_program(bignum_program); diff --git a/src/modules/HTTPLoop/accept_and_parse.c b/src/modules/HTTPLoop/accept_and_parse.c index 0e8e3dd14a5ff22fdcf2cc9e2ad0666c81c5f32b..3f902902bfe83be3b72dbf808934d7fc4d293e5f 100644 --- a/src/modules/HTTPLoop/accept_and_parse.c +++ b/src/modules/HTTPLoop/accept_and_parse.c @@ -2,7 +2,7 @@ || 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: accept_and_parse.c,v 1.38 2005/11/14 21:15:25 nilsson Exp $ +|| $Id: accept_and_parse.c,v 1.39 2008/01/26 22:34:25 mast Exp $ */ /* Hohum. Here we go. This is try number four for a more optimized @@ -553,7 +553,7 @@ static void finished_p(struct callback *foo, void *b, void *c) /* JMP_BUF recovery; */ /* free_svalue(& throw_value); */ -/* throw_value.type=T_INT; */ +/* mark_free_svalue (&throw_value); */ /* if(SETJMP(recovery)) */ /* { */ diff --git a/src/modules/HTTPLoop/requestobject.c b/src/modules/HTTPLoop/requestobject.c index da3309b4d202f90f59162e284a8c8d0ec71dc98d..306aa6baf317d0df1cee184eaf617585e63dab3b 100644 --- a/src/modules/HTTPLoop/requestobject.c +++ b/src/modules/HTTPLoop/requestobject.c @@ -2,7 +2,7 @@ || 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: requestobject.c,v 1.30 2005/05/06 00:48:32 nilsson Exp $ +|| $Id: requestobject.c,v 1.31 2008/01/26 22:34:25 mast Exp $ */ #include "global.h" @@ -593,6 +593,7 @@ void f_aap_index_op(INT32 args) else { sp[-1].type = T_INT; + sp[-1].subtype = NUMBER_NUMBER; sp[-1].u.integer = 0; } push_string(s_since); diff --git a/src/modules/Image/colortable.c b/src/modules/Image/colortable.c index 184f5dcb4cc85a906474884e69291bf9e08b294d..77b8c3ecfa91b58a696a49139d8ecedefad29c22 100644 --- a/src/modules/Image/colortable.c +++ b/src/modules/Image/colortable.c @@ -2,7 +2,7 @@ || 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: colortable.c,v 1.129 2008/01/24 22:45:36 grubba Exp $ +|| $Id: colortable.c,v 1.130 2008/01/26 22:34:25 mast Exp $ */ #include "global.h" @@ -918,7 +918,9 @@ rerun_mask: static struct nct_flat _img_get_flat_from_array(struct array *arr) { +#if 0 struct svalue s,s2; +#endif struct nct_flat flat; int i,n=0; @@ -926,7 +928,9 @@ static struct nct_flat _img_get_flat_from_array(struct array *arr) flat.entries=(struct nct_flat_entry*) xalloc(flat.numentries*sizeof(struct nct_flat_entry)); +#if 0 s2.type=s.type=T_INT; +#endif for (i=0; i<arr->size; i++) { if (arr->item[i].type==T_INT && !arr->item[i].u.integer) diff --git a/src/modules/Java/jvm.c b/src/modules/Java/jvm.c index e621c7b0825fc833dc1c5d4f715a46a2392a4586..1e20d72e2a31cf6774149ae631ce554041a45533 100644 --- a/src/modules/Java/jvm.c +++ b/src/modules/Java/jvm.c @@ -2,7 +2,7 @@ || 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: jvm.c,v 1.83 2008/01/17 16:36:11 grubba Exp $ +|| $Id: jvm.c,v 1.84 2008/01/26 22:34:25 mast Exp $ */ /* @@ -2035,7 +2035,7 @@ static void do_native_dispatch(void *arg) pop_n_elems(Pike_sp-osp); UNSETJMP(recovery); free_svalue(&throw_value); - throw_value.type = PIKE_T_INT; + mark_free_svalue (&throw_value); return; } diff --git a/src/modules/Parser/html.c b/src/modules/Parser/html.c index dd7aca80252425267036da9e82ab37c6688d9a7b..7a44936d36d1c367fb277c3f7a96c9fa3f65728b 100644 --- a/src/modules/Parser/html.c +++ b/src/modules/Parser/html.c @@ -2,7 +2,7 @@ || 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: html.c,v 1.177 2005/05/19 22:35:36 mast Exp $ +|| $Id: html.c,v 1.178 2008/01/26 22:34:25 mast Exp $ */ #include "global.h" @@ -3991,7 +3991,7 @@ static void html_read(INT32 args) struct out_piece *z = THIS->out; type_field |= 1 << z->v.type; ITEM(res)[i] = z->v; - z->v.type = T_INT; + mark_free_svalue (&z->v); THIS->out = THIS->out->next; really_free_out_piece (z); } @@ -4038,7 +4038,7 @@ static void html_read(INT32 args) if (THIS->out->v.u.string->len == n) { struct out_piece *z = THIS->out; push_string (z->v.u.string); - z->v.type = T_INT; + mark_free_svalue (&z->v); THIS->out = z->next; really_free_out_piece (z); } diff --git a/src/modules/Parser/xml.cmod b/src/modules/Parser/xml.cmod index 700771de9d965b61356f3245b07363b527ad9c14..d263abd9fe93e477804d82ccb6782a47d64f253e 100644 --- a/src/modules/Parser/xml.cmod +++ b/src/modules/Parser/xml.cmod @@ -1,8 +1,8 @@ -/* +/* -*- c -*- || 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: xml.cmod,v 1.96 2008/01/21 22:39:03 grubba Exp $ +|| $Id: xml.cmod,v 1.97 2008/01/26 22:34:26 mast Exp $ */ #include "global.h" diff --git a/src/modules/Postgres/postgres.c b/src/modules/Postgres/postgres.c index d17c26acdd4014bfcd307f951e0838c0f191756d..f736492aff629563d95faf1347c4a9cee0868b52 100644 --- a/src/modules/Postgres/postgres.c +++ b/src/modules/Postgres/postgres.c @@ -2,7 +2,7 @@ || 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: postgres.c,v 1.54 2008/01/20 22:30:03 grubba Exp $ +|| $Id: postgres.c,v 1.55 2008/01/26 22:34:26 mast Exp $ */ /* @@ -86,7 +86,7 @@ static void pgres_create (struct object * o) { THIS->dblink=NULL; THIS->last_error=NULL; THIS->notify_callback=(struct svalue*)xalloc(sizeof(struct svalue)); - THIS->notify_callback->type=PIKE_T_INT; + mark_free_svalue (&THIS->notify_callback); THIS->docommit=0; THIS->dofetch=0; THIS->lastcommit=0; @@ -115,9 +115,7 @@ static void pgres_destroy (struct object * o) free_string(THIS->last_error); THIS->last_error=NULL; } - if (THIS->notify_callback->type!=PIKE_T_INT) { - free_svalue(THIS->notify_callback); - } + free_svalue(THIS->notify_callback); free(THIS->notify_callback); #if defined(PIKE_THREADS) && defined(PQ_THREADSAFE) mt_destroy(&THIS->mutex); @@ -645,9 +643,9 @@ static void f_callback(INT32 args) args, BIT_INT|BIT_FUNCTION, 0); if (Pike_sp[-args].type==PIKE_T_INT) { - if (THIS->notify_callback->type!=PIKE_T_INT) { + if (THIS->notify_callback->type!=PIKE_T_FREE) { free_svalue(THIS->notify_callback); - THIS->notify_callback->type=PIKE_T_INT; + mark_free_svalue (&THIS->notify_callback); } pop_n_elems(args); return; diff --git a/src/modules/_math/math.c b/src/modules/_math/math.c index 252105ddc4222ba2859da39558a6ec7362a9021d..f57dd9a04aa8e183b11632050e055695ca6dc78b 100644 --- a/src/modules/_math/math.c +++ b/src/modules/_math/math.c @@ -2,7 +2,7 @@ || 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: math.c,v 1.86 2007/03/31 14:10:36 grubba Exp $ +|| $Id: math.c,v 1.87 2008/01/26 22:34:27 mast Exp $ */ #include "global.h" @@ -703,6 +703,7 @@ void f_abs(INT32 args) { struct svalue zero; zero.type=T_INT; + zero.subtype = NUMBER_NUMBER; zero.u.integer=0; check_all_args("abs",args,BIT_INT|BIT_FLOAT|BIT_OBJECT,0); diff --git a/src/modules/files/sendfile.c b/src/modules/files/sendfile.c index cd692017a3db838211f912896580cb43e6d38d21..bd63aecc3fe3790637314adbb2ee1f02283f67e7 100644 --- a/src/modules/files/sendfile.c +++ b/src/modules/files/sendfile.c @@ -2,7 +2,7 @@ || 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: sendfile.c,v 1.77 2008/01/23 22:20:02 grubba Exp $ +|| $Id: sendfile.c,v 1.78 2008/01/26 22:34:27 mast Exp $ */ /* @@ -202,6 +202,7 @@ static void exit_pike_sendfile(struct object *o) */ free_svalue(&(THIS->callback)); THIS->callback.type = T_INT; + THIS->callback.subtype = NUMBER_NUMBER; THIS->callback.u.integer = 0; if (THIS->backend_callback) { remove_callback (THIS->backend_callback); @@ -253,6 +254,7 @@ static void sf_call_callback(struct pike_sendfile *this) free_svalue(&this->callback); this->callback.type = T_INT; + this->callback.subtype = NUMBER_NUMBER; this->callback.u.integer = 0; } else { free_array(this->args); @@ -787,6 +789,7 @@ static void sf_create(INT32 args) */ free_svalue(&(THIS->callback)); THIS->callback.type = T_INT; + THIS->callback.subtype = NUMBER_NUMBER; THIS->callback.u.integer = 0; /* NOTE: The references to the stuff in sf are held by the stack. @@ -795,6 +798,7 @@ static void sf_create(INT32 args) MEMSET(&sf, 0, sizeof(struct pike_sendfile)); sf.callback.type = T_INT; + sf.callback.subtype = NUMBER_NUMBER; get_all_args("sendfile", args, "%A%O%l%l%A%o%*", &(sf.headers), &(sf.from_file), &offset, @@ -851,6 +855,7 @@ static void sf_create(INT32 args) sf.from_file = NULL; sf.from = NULL; sp[1-args].type = T_INT; + sp[1-args].subtype = NUMBER_NUMBER; sp[1-args].u.integer = 0; } diff --git a/src/modules/spider/spider.c b/src/modules/spider/spider.c index b79793a7e3eecf1890e4945351f2c686621cd460..d638291c4c951a0695a969a4d2b873051a87150a 100644 --- a/src/modules/spider/spider.c +++ b/src/modules/spider/spider.c @@ -2,7 +2,7 @@ || 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: spider.c,v 1.133 2007/06/02 04:11:30 mbaehr Exp $ +|| $Id: spider.c,v 1.134 2008/01/26 22:34:27 mast Exp $ */ #include "global.h" @@ -263,7 +263,7 @@ void f_parse_html_lines(INT32 args) return; } - sp[-args].type=T_INT; + mark_free_svalue (sp - args); add_ref(single=sp[1-args].u.mapping); add_ref(cont=sp[2-args].u.mapping); diff --git a/src/multiset.c b/src/multiset.c index a22fbcecb6913dfcba09d590b66b882934e104ff..f4ef4fa09ec63eda0d224273d1364eee6bc850dc 100644 --- a/src/multiset.c +++ b/src/multiset.c @@ -2,7 +2,7 @@ || 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: multiset.c,v 1.105 2007/12/27 22:11:04 nilsson Exp $ +|| $Id: multiset.c,v 1.106 2008/01/26 22:34:22 mast Exp $ */ #include "global.h" @@ -870,11 +870,7 @@ PMOD_EXPORT struct multiset *real_allocate_multiset (int allocsize, * multisets with allocsize, since prepare_for_add shrinks them. */ #ifdef PIKE_DEBUG - if (cmp_less) { - if(cmp_less->type == T_INT) - cmp_less->subtype = NUMBER_NUMBER; - check_svalue (cmp_less); - } + if (cmp_less) check_svalue (cmp_less); #endif if (allocsize || cmp_less || (flags & ~MULTISET_INDVAL)) { @@ -882,7 +878,10 @@ PMOD_EXPORT struct multiset *real_allocate_multiset (int allocsize, add_ref (l->msd); fix_free_list (l->msd, 0); if (cmp_less) assign_svalue_no_free (&l->msd->cmp_less, cmp_less); - else l->msd->cmp_less.type = T_INT; + else { + l->msd->cmp_less.type = T_INT; + l->msd->cmp_less.subtype = NUMBER_NUMBER; + } } else { l->msd = flags & MULTISET_INDVAL ? &empty_indval_msd : &empty_ind_msd; @@ -1040,6 +1039,7 @@ PMOD_EXPORT void multiset_set_flags (struct multiset *l, int flags) COPY_NODE_IND (onode, nnode, TYPE); \ INDVAL ( \ nnode->val.type = T_INT; \ + nnode->val.subtype = NUMBER_NUMBER; \ nnode->val.u.integer = 1; \ ); \ } \ @@ -1067,11 +1067,7 @@ PMOD_EXPORT void multiset_set_cmp_less (struct multiset *l, #ifdef PIKE_DEBUG debug_malloc_touch (l); debug_malloc_touch (old); - if (cmp_less) { - if(cmp_less->type == T_INT) - cmp_less->subtype = NUMBER_NUMBER; - check_svalue (cmp_less); - } + if (cmp_less) check_svalue (cmp_less); #endif again: @@ -1084,7 +1080,10 @@ again: if (prepare_for_change (l, l->node_refs)) old = l->msd; free_svalue (&old->cmp_less); if (cmp_less) assign_svalue_no_free (&old->cmp_less, cmp_less); - else old->cmp_less.type = T_INT; + else { + old->cmp_less.type = T_INT; + old->cmp_less.subtype = NUMBER_NUMBER; + } } else { @@ -1103,7 +1102,10 @@ again: free_svalue (&new.msd->cmp_less); if (cmp_less) assign_svalue_no_free (&new.msd->cmp_less, cmp_less); - else new.msd->cmp_less.type = T_INT; + else { + new.msd->cmp_less.type = T_INT; + new.msd->cmp_less.subtype = NUMBER_NUMBER; + } do { low_use_multiset_index (new.list, ind); @@ -1170,11 +1172,7 @@ PMOD_EXPORT struct multiset *mkmultiset_2 (struct array *indices, if (values && values->size != indices->size) Pike_fatal ("Indices and values not of same size (%d vs %d).\n", indices->size, values->size); - if (cmp_less) { - if(cmp_less->type == T_INT) - cmp_less->subtype = NUMBER_NUMBER; - check_svalue (cmp_less); - } + if (cmp_less) check_svalue (cmp_less); #endif new.l = NULL, new.msd2 = NULL; @@ -1182,7 +1180,10 @@ PMOD_EXPORT struct multiset *mkmultiset_2 (struct array *indices, values ? MULTISET_INDVAL : 0); if (cmp_less) assign_svalue_no_free (&new.msd->cmp_less, cmp_less); - else new.msd->cmp_less.type = T_INT; + else { + new.msd->cmp_less.type = T_INT; + new.msd->cmp_less.subtype = NUMBER_NUMBER; + } if (!indices->size) fix_free_list (new.msd, 0); @@ -2024,6 +2025,7 @@ PMOD_EXPORT void multiset_insert (struct multiset *l, } \ else { \ NEW->iv.val.type = T_INT; \ + NEW->iv.val.subtype = NUMBER_NUMBER; \ NEW->iv.val.u.integer = 1; \ MSD->val_types |= BIT_INT; \ } \ @@ -2136,6 +2138,7 @@ PMOD_EXPORT ptrdiff_t multiset_insert_2 (struct multiset *l, else { free_svalue (&RBNODE (node)->iv.val); RBNODE (node)->iv.val.type = T_INT; + RBNODE (node)->iv.val.subtype = NUMBER_NUMBER; RBNODE (node)->iv.val.u.integer = 1; msd->val_types |= BIT_INT; } @@ -2513,6 +2516,7 @@ PMOD_EXPORT int multiset_delete_2 (struct multiset *l, move_svalue (removed_val, &val); else { removed_val->type = T_INT; + removed_val->subtype = NUMBER_NUMBER; removed_val->u.integer = 1; } else @@ -3725,7 +3729,11 @@ struct multiset *copy_multiset_recursively (struct multiset *l, pos++; new.node->i.ind.type = T_INT; - if (got_values) new.node->iv.val.type = T_INT; + new.node->i.ind.subtype = NUMBER_NUMBER; + if (got_values) { + new.node->iv.val.type = T_INT; + new.node->iv.val.type = NUMBER_NUMBER; + } low_use_multiset_index (node, ind); if (!IS_DESTRUCTED (&ind)) { diff --git a/src/object.c b/src/object.c index 88f901521a69e1e3cb39effb53d1f4594aaaf8c9..895fb9ab8fd68e3e49a91b19c4bb700bddb77af9 100644 --- a/src/object.c +++ b/src/object.c @@ -2,7 +2,7 @@ || 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: object.c,v 1.280 2008/01/24 18:34:19 grubba Exp $ +|| $Id: object.c,v 1.281 2008/01/26 22:34:22 mast Exp $ */ #include "global.h" @@ -607,7 +607,7 @@ PMOD_EXPORT struct object *get_master(void) /* do nothing */ UNSETJMP(tmp); free_svalue(&throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); }else{ f_decode_value(2); UNSETJMP(tmp); @@ -743,14 +743,14 @@ static void call_destroy(struct object *o, enum object_destruct_reason reason) #endif free_svalue (&throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); if (SETJMP (jmp)) { UNSETJMP (jmp); if (gc_destruct_everything) { struct svalue err; move_svalue (&err, &throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); if (!SETJMP (jmp)) { push_svalue (&err); push_int (0); diff --git a/src/operators.c b/src/operators.c index 5578c9bcf9a11aeb2b41075afcf39b0cfe835dd1..11a3fc7124d11fb4bf5328c01b6af1f4371017d0 100644 --- a/src/operators.c +++ b/src/operators.c @@ -2,7 +2,7 @@ || 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: operators.c,v 1.225 2008/01/24 17:48:18 mast Exp $ +|| $Id: operators.c,v 1.226 2008/01/26 22:34:22 mast Exp $ */ #include "global.h" @@ -1491,7 +1491,7 @@ PMOD_EXPORT void f_add(INT32 args) tmp=sp[-args].u.string->len; r=new_realloc_shared_string(sp[-args].u.string,size,max_shift); - sp[-args].type=T_INT; + mark_free_svalue (sp - args); buf=MKPCHARP_STR_OFF(r,tmp); for(e=-args+1;e<0;e++) { @@ -5367,7 +5367,9 @@ static void f_string_assignment_assign_index(INT32 args) static void init_string_assignment_storage(struct object *o) { THIS->lval[0].type = T_INT; + THIS->lval[0].subtype = PIKE_T_FREE; THIS->lval[1].type = T_INT; + THIS->lval[1].subtype = PIKE_T_FREE; THIS->s = NULL; } diff --git a/src/pike_error.h b/src/pike_error.h index dcdb396d006c8673f8c85802886ac263b565d538..ff94478d38721666048035fa0b24aefb662207b1 100644 --- a/src/pike_error.h +++ b/src/pike_error.h @@ -2,7 +2,7 @@ || 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: pike_error.h,v 1.41 2007/07/03 08:54:37 mast Exp $ +|| $Id: pike_error.h,v 1.42 2008/01/26 22:34:22 mast Exp $ */ #ifndef PIKE_ERROR_H @@ -386,7 +386,7 @@ PMOD_EXPORT extern const char msg_div_by_zero[]; __exception_rethrow = 1; \ if(__is_exception) { \ free_svalue(&throw_value); \ - throw_value.type = T_INT; \ + mark_free_svalue (&throw_value); \ } \ else \ UNSETJMP(exception); \ diff --git a/src/post_modules/Shuffler/Shuffler.cmod b/src/post_modules/Shuffler/Shuffler.cmod index 798cd5bcf220280983764660a3c20396f6264727..6d588c4ed1071de2b76224291ca44931fac8bd48 100644 --- a/src/post_modules/Shuffler/Shuffler.cmod +++ b/src/post_modules/Shuffler/Shuffler.cmod @@ -2,7 +2,7 @@ || 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: Shuffler.cmod,v 1.44 2008/01/21 22:53:58 grubba Exp $ +|| $Id: Shuffler.cmod,v 1.45 2008/01/26 22:34:27 mast Exp $ */ #include "global.h" @@ -210,8 +210,9 @@ PIKECLASS Shuffle THIS->shuffler = 0; THIS->throttler = 0; THIS->sent = 0; - THIS->done_callback.type = PIKE_T_INT; + mark_free_svalue (&THIS->done_callback); THIS->request_arg.type = PIKE_T_INT; + THIS->request_arg.subtype = NUMBER_NUMBER; THIS->request_arg.u.integer = 0; THIS->leftovers.len = 0; THIS->current_source = NULL; @@ -343,7 +344,7 @@ PIKECLASS Shuffle /* If a callback exists, we call it before destroying * source and destination */ - if( t->done_callback.type != PIKE_T_INT ) + if( t->done_callback.type != PIKE_T_FREE ) { SHUFFLE_DEBUG3("_all_done(%d): Calling done callback: %p\n", t, reason, t->done_callback.u.object); @@ -404,6 +405,8 @@ PIKECLASS Shuffle { SHUFFLE_DEBUG2("set_done_callback(%p)\n", THIS, cb->u.object ); assign_svalue( &THIS->done_callback,cb); + if (THIS->done_callback.type == PIKE_T_INT) + mark_free_svalue (&THIS->done_callback); } PIKEFUN void set_request_arg( mixed arg ) diff --git a/src/post_modules/_ADT/circular_list.cmod b/src/post_modules/_ADT/circular_list.cmod index c7757eec34b0cb5614d872e858c07a5281a5e19c..a620575736ca068e9c502492f045fbc9c1e613c6 100644 --- a/src/post_modules/_ADT/circular_list.cmod +++ b/src/post_modules/_ADT/circular_list.cmod @@ -2,7 +2,7 @@ || 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: circular_list.cmod,v 1.17 2006/08/06 14:33:51 mast Exp $ +|| $Id: circular_list.cmod,v 1.18 2008/01/26 22:34:27 mast Exp $ */ #include "global.h" @@ -90,6 +90,7 @@ PIKECLASS CircularList FIX_AND_CHECK_INDEX(index, THIS->size, 0); ind.u.integer = circ2array(index); ind.type = T_INT; + ind.subtype = NUMBER_NUMBER; simple_array_index_no_free(Pike_sp, THIS->a, &ind); Pike_sp++; } @@ -117,7 +118,8 @@ PIKECLASS CircularList FIX_AND_CHECK_INDEX(index, THIS->size, 0); ind.u.integer = circ2array(index); ind.type = T_INT; - should_copy(); + ind.subtype = NUMBER_NUMBER; + should_copy(); simple_set_index(THIS->a, &ind, value); pop_n_elems(args); } @@ -472,6 +474,7 @@ PIKECLASS CircularList } ind.u.integer = THIS->pos; ind.type = T_INT; + ind.subtype = NUMBER_NUMBER; simple_set_index(THIS->a, &ind, value); THIS->size++; pop_n_elems(args); @@ -673,6 +676,7 @@ PIKECLASS CircularList } ind.u.integer=circ2array(THIS->size-1); ind.type =T_INT; + ind.subtype = NUMBER_NUMBER; simple_array_index_no_free(Pike_sp, THIS->a, &ind); Pike_sp++; } @@ -692,6 +696,7 @@ PIKECLASS CircularList } ind.u.integer=THIS->pos; ind.type =T_INT; + ind.subtype = NUMBER_NUMBER; simple_array_index_no_free(Pike_sp, THIS->a, &ind); Pike_sp++; } @@ -717,8 +722,10 @@ PIKECLASS CircularList THIS->size--; ind.u.integer=circ2array(THIS->size); ind.type =T_INT; + ind.subtype = NUMBER_NUMBER; zero.u.integer=0; zero.type =T_INT; + zero.subtype = NUMBER_NUMBER; simple_array_index_no_free(Pike_sp, THIS->a, &ind); simple_set_index(THIS->a, &ind, &zero); Pike_sp++; @@ -745,8 +752,10 @@ PIKECLASS CircularList should_copy(); ind.u.integer=THIS->pos; ind.type =T_INT; + ind.subtype = NUMBER_NUMBER; zero.u.integer=0; zero.type =T_INT; + zero.subtype = NUMBER_NUMBER; if (++THIS->pos >= THIS->a->size) { THIS->pos = 0; @@ -777,6 +786,7 @@ PIKECLASS CircularList ind.u.integer=circ2array(THIS->size); ind.type =T_INT; + ind.subtype = NUMBER_NUMBER; THIS->size++; simple_set_index(THIS->a, &ind, value); } @@ -805,6 +815,7 @@ PIKECLASS CircularList } ind.u.integer = THIS->pos; ind.type = T_INT; + ind.subtype = NUMBER_NUMBER; simple_set_index(THIS->a, &ind, value); THIS->size++; pop_n_elems(args); @@ -1251,6 +1262,7 @@ PIKECLASS CircularList ind.u.integer = (THIS->pos+THIS->list->pos)%THIS->list->a->size; ind.type = T_INT; + ind.subtype = NUMBER_NUMBER; simple_array_index_no_free(&retval, THIS->list->a, &ind); simple_set_index(THIS->list->a, &ind, val); push_svalue(&retval); @@ -1305,6 +1317,7 @@ PIKECLASS CircularList struct svalue ind; ind.u.integer=THIS_CIRCULARLIST->size; ind.type=T_INT; + ind.subtype = NUMBER_NUMBER; ref_push_object(Pike_fp->current_object); push_svalue(&ind); push_object(clone_object(CircularList_CircularListIterator_program, 2)); diff --git a/src/post_modules/_ADT/sequence.cmod b/src/post_modules/_ADT/sequence.cmod index 06b9e3f1e8cbce3ffae4c3c337fd25d34319785f..443bedd4bd95bc6592351ddea91f65a2124789e1 100644 --- a/src/post_modules/_ADT/sequence.cmod +++ b/src/post_modules/_ADT/sequence.cmod @@ -2,7 +2,7 @@ || 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: sequence.cmod,v 1.18 2006/08/06 14:33:51 mast Exp $ +|| $Id: sequence.cmod,v 1.19 2008/01/26 22:34:27 mast Exp $ */ #include "global.h" @@ -928,6 +928,7 @@ PIKECLASS Sequence ind.u.integer = THIS->pos; ind.type = T_INT; + ind.subtype = NUMBER_NUMBER; simple_array_index_no_free(&retval, THIS->sequence->a, &ind); simple_set_index(THIS->sequence->a, &ind, val); push_svalue(&retval); @@ -981,6 +982,7 @@ PIKECLASS Sequence struct svalue ind; ind.u.integer=THIS_SEQUENCE->a->size; ind.type=T_INT; + ind.subtype = NUMBER_NUMBER; ref_push_object(Pike_fp->current_object); push_svalue(&ind); push_object(clone_object(Sequence_SequenceIterator_program, 2)); diff --git a/src/program.c b/src/program.c index 29b6209f48e295990b3ffaf7717fc9997f90aab8..d687fb1d9a75d0039bd6ebee7cd68de846b57ed6 100644 --- a/src/program.c +++ b/src/program.c @@ -2,7 +2,7 @@ || 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: program.c,v 1.641 2008/01/24 13:58:26 mast Exp $ +|| $Id: program.c,v 1.642 2008/01/26 22:34:23 mast Exp $ */ #include "global.h" @@ -1657,7 +1657,7 @@ struct node_s *resolve_identifier(struct pike_string *ident) if (throw_value.type == T_STRING) { my_yyerror("%S", throw_value.u.string); free_svalue(&throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); } else { handle_compile_exception ("Error resolving %S.", ident); @@ -1668,7 +1668,7 @@ struct node_s *resolve_identifier(struct pike_string *ident) * least in rtldebug mode, but this borken, borken, boRKen. :P */ struct svalue thrown; move_svalue (&thrown, &throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); #ifdef PIKE_DEBUG { struct pike_string *msg = format_exception_for_error_msg (&thrown); @@ -6754,7 +6754,7 @@ void handle_compile_exception (const char *yyerror_fmt, ...) { struct svalue thrown; move_svalue (&thrown, &throw_value); - throw_value.type = T_INT; + mark_free_svalue (&throw_value); if (yyerror_fmt) { va_list args; @@ -7350,6 +7350,7 @@ static void run_cleanup(struct compilation *c, int delayed) for (i = 0; i < p->num_constants; i++) { free_svalue(&p->constants[i].sval); p->constants[i].sval.type = T_INT; + p->constants[i].sval.subtype = NUMBER_NUMBER; } } @@ -7468,6 +7469,7 @@ struct program *compile(struct pike_string *aprog, if((c->target=atarget)) add_ref(atarget); if((c->placeholder=aplaceholder)) add_ref(aplaceholder); c->default_module.type=T_INT; + c->default_module.subtype = NUMBER_NUMBER; if (c->handler) { @@ -8143,6 +8145,7 @@ size_t gc_free_all_unreferenced_programs(void) { free_svalue(& p->constants[e].sval); p->constants[e].sval.type=T_INT; + p->constants[e].sval.subtype = NUMBER_NUMBER; } for(e=0;e<p->num_inherits;e++) diff --git a/src/signal_handler.c b/src/signal_handler.c index be87b5bf1a79b57354cc68d8ce6d0c05e6913fb9..60348c537f723cc3f205039feb72ba3b88457f37 100644 --- a/src/signal_handler.c +++ b/src/signal_handler.c @@ -2,7 +2,7 @@ || 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: signal_handler.c,v 1.330 2008/01/13 18:21:32 grubba Exp $ +|| $Id: signal_handler.c,v 1.331 2008/01/26 22:34:23 mast Exp $ */ #include "global.h" @@ -1146,6 +1146,7 @@ static void init_pid_status(struct object *o) THIS->state=PROCESS_UNKNOWN; THIS->result=-1; THIS->callback.type = T_INT; + THIS->callback.subtype = NUMBER_NUMBER; THIS->callback.u.integer = 0; #endif } @@ -1157,6 +1158,7 @@ static void exit_pid_status(struct object *o) { struct svalue key; key.type=PIKE_T_INT; + key.subtype = NUMBER_NUMBER; key.u.integer=THIS->pid; map_delete(pid_mapping, &key); } @@ -4805,8 +4807,10 @@ void init_signals(void) init_interleave_mutex(&handle_protection_mutex); #endif /* __NT__ */ - for(e=0;e<MAX_SIGNALS;e++) + for(e=0;e<MAX_SIGNALS;e++) { signal_callbacks[e].type = PIKE_T_INT; + signal_callbacks[e].subtype = NUMBER_NUMBER; + } low_init_signals(); @@ -4954,5 +4958,6 @@ void exit_signals(void) { free_svalue(signal_callbacks+e); signal_callbacks[e].type = PIKE_T_INT; + signal_callbacks[e].subtype = NUMBER_NUMBER; } } diff --git a/src/sscanf.c b/src/sscanf.c index 6778cee87d18aa3c36bbbda889e0e73b250f7c03..ba26ab861b7a6dc46bd4675c901540a396ff3b53 100644 --- a/src/sscanf.c +++ b/src/sscanf.c @@ -2,7 +2,7 @@ || 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: sscanf.c,v 1.169 2007/05/20 19:16:48 nilsson Exp $ +|| $Id: sscanf.c,v 1.170 2008/01/26 22:34:24 mast Exp $ */ #include "global.h" @@ -1202,6 +1202,7 @@ CHAROPT2( \ INT32 x; \ struct svalue tmp; \ tmp.type=T_INT; \ + tmp.subtype = NUMBER_NUMBER; \ tmp.u.integer=input[eye]; \ x=switch_lookup(set.a, &tmp); \ if( set.neg != (x<0 && (x&1)) ) break; \ diff --git a/src/svalue.c b/src/svalue.c index a8cf777c480ed30824b158cc6724dc6fc22396b3..bda36f443277f6abcb9110366b7209094012d675 100644 --- a/src/svalue.c +++ b/src/svalue.c @@ -2,7 +2,7 @@ || 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: svalue.c,v 1.233 2007/10/12 13:31:05 mast Exp $ +|| $Id: svalue.c,v 1.234 2008/01/26 22:34:24 mast Exp $ */ #include "global.h" @@ -97,71 +97,57 @@ PMOD_EXPORT void really_free_short_svalue_ptr(void **s, TYPE_T type) PMOD_EXPORT void really_free_svalue(struct svalue *s) { - int tmp=s->type; - s->type=T_INT; - switch(tmp) + struct svalue tmp; + move_svalue (&tmp, s); + mark_free_svalue (s); + + switch(tmp.type) { case T_ARRAY: - really_free_array(s->u.array); -#ifdef PIKE_DEBUG - s->type = 99; -#endif + really_free_array(tmp.u.array); break; case T_MAPPING: - really_free_mapping(s->u.mapping); -#ifdef PIKE_DEBUG - s->type = 99; -#endif + really_free_mapping(tmp.u.mapping); break; case T_MULTISET: - really_free_multiset(s->u.multiset); -#ifdef PIKE_DEBUG - s->type = 99; -#endif + really_free_multiset(tmp.u.multiset); break; case T_FUNCTION: - if(s->subtype == FUNCTION_BUILTIN) + if(tmp.subtype == FUNCTION_BUILTIN) { - really_free_callable(s->u.efun); + really_free_callable(tmp.u.efun); break; } /* fall through */ case T_OBJECT: - schedule_really_free_object(s->u.object); - break; + schedule_really_free_object(tmp.u.object); + return; case T_PROGRAM: - really_free_program(s->u.program); -#ifdef PIKE_DEBUG - s->type = 99; -#endif + really_free_program(tmp.u.program); break; case T_TYPE: /* Add back the reference, and call the normal free_type(). */ - add_ref(s->u.type); - free_type(s->u.type); -#ifdef PIKE_DEBUG - s->type = 99; -#endif /* PIKE_DEBUG */ + add_ref(tmp.u.type); + free_type(tmp.u.type); break; case T_STRING: - really_free_string(s->u.string); -#ifdef PIKE_DEBUG - s->type = 99; -#endif + really_free_string(tmp.u.string); break; #ifdef PIKE_DEBUG default: - Pike_fatal("Bad type in free_svalue.\n"); + Pike_fatal("Bad type in really_free_svalue.\n"); #endif } + + assert_free_svalue (s); } PMOD_EXPORT void do_free_svalue(struct svalue *s) @@ -185,10 +171,9 @@ PMOD_EXPORT void debug_free_svalues(struct svalue *s, size_t num, INT32 type_hin #define DOTYPE(X,Y,Z) case X: \ while(num--) { \ - DO_IF_DMALLOC(debug_malloc_update_location(s->u.Z, dmalloc_location)); \ + DO_IF_DMALLOC(debug_malloc_update_location(s->u.Z, dmalloc_location)); \ Y(s->u.Z); \ - DO_IF_DMALLOC(s->u.Z=(void *)-1); \ - PIKE_MEM_WO(s->u.Z); \ + assert_free_svalue (s); \ s++; \ }return @@ -244,8 +229,6 @@ PMOD_EXPORT void debug_free_svalues(struct svalue *s, size_t num, INT32 type_hin if(!sub_ref(s->u.dummy)) { really_free_svalue(s); - DO_IF_DMALLOC(s->u.refs=0); - PIKE_MEM_WO(*s); } s++; } @@ -263,8 +246,7 @@ PMOD_EXPORT void debug_free_svalues(struct svalue *s, size_t num, INT32 type_hin really_free_callable(s->u.efun); else schedule_really_free_object(s->u.object); - DO_IF_DMALLOC(s->u.refs=0); - PIKE_MEM_WO(*s); + assert_free_svalue (s); } s++; } @@ -2049,7 +2031,10 @@ PMOD_EXPORT void real_gc_mark_external_svalues(const struct svalue *s, ptrdiff_t for(e=0;e<num;e++,s++) { - check_svalue((struct svalue *) s); +#ifdef PIKE_DEBUG + if (s->type != PIKE_T_FREE) + check_svalue((struct svalue *) s); +#endif gc_svalue_location=(void *)s; diff --git a/src/svalue.h b/src/svalue.h index 25593973ba20642be29f08dee8967e63c58d9f8b..a503242c098743110dca406b9e6ce0a19ec203b6 100644 --- a/src/svalue.h +++ b/src/svalue.h @@ -2,7 +2,7 @@ || 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: svalue.h,v 1.148 2007/10/12 13:31:05 mast Exp $ +|| $Id: svalue.h,v 1.149 2008/01/26 22:34:24 mast Exp $ */ #ifndef SVALUE_H @@ -128,6 +128,18 @@ struct svalue #define PIKE_T_GET_SET 32 /* Getter setter. * Only valid in struct identifier */ +/* Type to put in freed svalues. Only the type field in such svalues + * is defined. Freeing a PIKE_T_FREE svalue is allowed and does + * nothing. mark_free_svalue() is preferably used to set this type. + * + * Traditionally T_INT has been used for this without setting a proper + * subtype; if T_INT is to be used then the subtype must be set to + * NUMBER_NUMBER. + * + * PIKE_T_FREE svalues are recorded as BIT_INT in type hint fields. + */ +#define PIKE_T_FREE 237 + #define PIKE_T_ATTRIBUTE 238 /* Attribute node. */ #define PIKE_T_NSTRING 239 /* Narrow string. Only for serialization. */ #define PIKE_T_RING 240 @@ -481,6 +493,28 @@ static INLINE union anything *dmalloc_check_union(union anything *u,int type, ch #endif /* !PIKE_DEBUG */ +/* This marks an svalue as free. After this it may only be used as + * input to the svalue free functions (which do nothing with it). Only + * the type field is defined (see PIKE_T_FREE above). */ +#define mark_free_svalue(X) do { \ + struct svalue *_X__ = (X); \ + DO_IF_DMALLOC (_X__->u.refs = (void *) -1); \ + PIKE_MEM_WO(*_X__); \ + _X__->type = PIKE_T_FREE; \ + } while (0) + +/* This is a debug macro to assert that an svalue is free and + * shouldn't be read at all until it's overwritten. As opposed to + * mark_free_svalue, it is not valid input to the svalue free + * functions and no field in it is defined. */ +#define assert_free_svalue(X) do { \ + DO_IF_DEBUG ( \ + struct svalue *_X__ = (X); \ + _X__->type = PIKE_T_UNKNOWN; \ + _X__->u.refs = (void *) -1; \ + PIKE_MEM_WO (*_X__); \ + ); \ + } while (0) /* This define * should check that the svalue address (X) is on the local stack, @@ -502,15 +536,20 @@ static INLINE union anything *dmalloc_check_union(union anything *u,int type, ch _tmp=*_a; *_a=*_b; *_b=_tmp; \ }while(0) +/* Handles PIKE_T_FREE. */ #define free_svalue_unlocked(X) do { \ struct svalue *_s=(X); \ assert_svalue_locked(_s); \ - check_type(_s->type); check_refs(_s); \ - if(_s->type<=MAX_REF_TYPE) { \ - if(sub_ref(_s->u.dummy) <=0) { really_free_svalue(_s); } \ - } \ - DO_IF_DMALLOC(_s->type=PIKE_T_UNKNOWN;_s->u.refs=(void *)-1); \ - PIKE_MEM_WO(*_s); \ + DO_IF_DEBUG ( \ + if (_s->type != PIKE_T_FREE) { \ + check_type(_s->type); \ + check_refs(_s); \ + } \ + ); \ + if(_s->type<=MAX_REF_TYPE && sub_ref(_s->u.dummy) <=0) \ + really_free_svalue(_s); \ + else \ + assert_free_svalue (_s); \ }while(0) #define free_short_svalue_unlocked(X,T) do { \ @@ -524,24 +563,35 @@ static INLINE union anything *dmalloc_check_union(union anything *u,int type, ch PIKE_MEM_WO(_s->refs); \ }while(0) +/* Handles PIKE_T_FREE. */ #define add_ref_svalue_unlocked(X) do { \ struct svalue *_tmp=(X); \ - check_type(_tmp->type); check_refs(_tmp); \ + DO_IF_DEBUG ( \ + if (_tmp->type != PIKE_T_FREE) { \ + check_type(_tmp->type); \ + check_refs(_tmp); \ + } \ + ); \ if(_tmp->type <= MAX_REF_TYPE) add_ref(_tmp->u.dummy); \ }while(0) +/* Handles PIKE_T_FREE. */ #define assign_svalue_no_free_unlocked(X,Y) do { \ struct svalue *_to=(X); \ const struct svalue *_from=(Y); \ - check_type(_from->type); check_refs(_from); \ - DO_IF_DEBUG(if (_to == _from) { \ - Pike_fatal(msg_assign_svalue_error, \ - _to); \ - }); \ + DO_IF_DEBUG ( \ + if (_from->type != PIKE_T_FREE) { \ + check_type(_from->type); \ + check_refs(_from); \ + } \ + if (_to == _from) \ + Pike_fatal(msg_assign_svalue_error, _to); \ + ); \ *_to=*_from; \ if(_to->type <= MAX_REF_TYPE) add_ref(_to->u.dummy); \ }while(0) +/* Handles PIKE_T_FREE. */ #define assign_svalue_unlocked(X,Y) do { \ struct svalue *_to2=(X); \ const struct svalue *_from2=(Y); \ @@ -551,17 +601,18 @@ static INLINE union anything *dmalloc_check_union(union anything *u,int type, ch } \ }while(0) +/* Handles PIKE_T_FREE. */ #define move_svalue(TO, FROM) do { \ struct svalue *_to = (TO); \ struct svalue *_from = (FROM); \ dmalloc_touch_svalue(_from); \ *_to = *_from; \ - DO_IF_DMALLOC(_from->type = PIKE_T_UNKNOWN; _from->u.refs = (void *) -1); \ - PIKE_MEM_WO(*_from); \ + assert_free_svalue (_from); \ } while (0) extern const struct svalue dest_ob_zero; +/* Handles PIKE_T_FREE. */ #define free_mixed_svalues(X,Y) do { \ struct svalue *s_=(X); \ ptrdiff_t num_=(Y); \ @@ -572,6 +623,7 @@ extern const struct svalue dest_ob_zero; } \ }while(0) +/* Handles PIKE_T_FREE. */ #ifdef DEBUG_MALLOC #define free_svalues(X,Y,Z) debug_free_svalues((X),(Y),(Z), DMALLOC_NAMED_LOCATION(" free_svalues")); #else @@ -767,6 +819,7 @@ static INLINE void free_svalue(struct svalue *s) INT64 tmp; struct svalue zero; zero.type=PIKE_T_INT; + zero.subtype = NUMBER_NUMBER; tmp=pike_atomic_swap64((INT64 *)s, *(INT64 *)&zero); free_svalue_unlocked((struct svalue *)&tmp); }