| 3661 | } |
| 3662 | |
| 3663 | void function_free( FUNCTION * function_ ) |
| 3664 | { |
| 3665 | int i; |
| 3666 | |
| 3667 | if ( --function_->reference_count != 0 ) |
| 3668 | return; |
| 3669 | |
| 3670 | if ( function_->formal_arguments ) |
| 3671 | argument_list_free( function_->formal_arguments, |
| 3672 | function_->num_formal_arguments ); |
| 3673 | |
| 3674 | if ( function_->type == FUNCTION_JAM ) |
| 3675 | { |
| 3676 | JAM_FUNCTION * func = (JAM_FUNCTION *)function_; |
| 3677 | |
| 3678 | BJAM_FREE( func->code ); |
| 3679 | |
| 3680 | if ( func->generic ) |
| 3681 | function_free( func->generic ); |
| 3682 | else |
| 3683 | { |
| 3684 | if ( function_->rulename ) object_free( function_->rulename ); |
| 3685 | |
| 3686 | for ( i = 0; i < func->num_constants; ++i ) |
| 3687 | object_free( func->constants[ i ] ); |
| 3688 | BJAM_FREE( func->constants ); |
| 3689 | |
| 3690 | for ( i = 0; i < func->num_subfunctions; ++i ) |
| 3691 | { |
| 3692 | object_free( func->functions[ i ].name ); |
| 3693 | function_free( func->functions[ i ].code ); |
| 3694 | } |
| 3695 | BJAM_FREE( func->functions ); |
| 3696 | |
| 3697 | for ( i = 0; i < func->num_subactions; ++i ) |
| 3698 | { |
| 3699 | object_free( func->actions[ i ].name ); |
| 3700 | function_free( func->actions[ i ].command ); |
| 3701 | } |
| 3702 | BJAM_FREE( func->actions ); |
| 3703 | |
| 3704 | object_free( func->file ); |
| 3705 | } |
| 3706 | } |
| 3707 | #ifdef HAVE_PYTHON |
| 3708 | else if ( function_->type == FUNCTION_PYTHON ) |
| 3709 | { |
| 3710 | PYTHON_FUNCTION * func = (PYTHON_FUNCTION *)function_; |
| 3711 | Py_DECREF( func->python_function ); |
| 3712 | if ( function_->rulename ) object_free( function_->rulename ); |
| 3713 | } |
| 3714 | #endif |
| 3715 | else |
| 3716 | { |
| 3717 | assert( function_->type == FUNCTION_BUILTIN ); |
| 3718 | if ( function_->rulename ) object_free( function_->rulename ); |
| 3719 | } |
| 3720 |
no test coverage detected