Ignore:
Timestamp:
Oct 20, 2013 7:33:35 PM (7 years ago)
Author:
bradbell
Message:

Use index instead of pointer because pointer can become invalid when vector grows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/opt_cond_exp/cppad/local/recorder.hpp

    r2978 r2980  
    110110        inline void PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3,
    111111                addr_t arg4, addr_t arg5);
    112         /// Reserve spacke for a specified number or arguments
    113         inline addr_t* ReserveArg(size_t n_arg);
     112
     113        // Reserve space for a specified number of arguments
     114        inline size_t ReserveArg(size_t n_arg);
     115
     116        // Replace an argument value
     117        void ReplaceArg(size_t i_arg, size_t value);
    114118
    115119        /// Put a character string in the text for this recording.
     
    436440
    437441\return
    438 point to the first argument; i.e., if arg is the return value,
    439 arg[0] throught arg[n_arg-1] are the arguments.
    440 */
    441 template <class Base>
    442 inline addr_t* recorder<Base>::ReserveArg(size_t n_arg)
     442is the index in the argument vector corresponding to the
     443first of the arguments being reserved.
     444*/
     445template <class Base>
     446inline size_t recorder<Base>::ReserveArg(size_t n_arg)
    443447{
    444448        size_t i = rec_op_arg_.extend(n_arg);
    445449        CPPAD_ASSERT_UNKNOWN( rec_op_arg_.size() == i + n_arg );
    446         return rec_op_arg_.data() + i;
    447 }
     450        return i;
     451}
     452
     453/*!
     454\brief
     455Replace an argument value in the recording
     456(intended to fill in reserved values).
     457
     458\param i_arg
     459is the index, in argument vector, for the value that is replaced.
     460
     461\param value
     462is the new value for the argument with the specified index.
     463*/
     464template <class Base>
     465inline void recorder<Base>::ReplaceArg(size_t i_arg, size_t value)
     466{       rec_op_arg_[i_arg] =  static_cast<addr_t>( value ); }
    448467// --------------------------------------------------------------------------
    449468/*!
Note: See TracChangeset for help on using the changeset viewer.