Revision 752 branches/threaded2/src/linad99/fvar2.cpp

fvar2.cpp (revision 752)
33 33
 * Description not yet available.
34 34
 * \param
35 35
 */
36
double_and_int * gradnew()
36
double_and_int* gradnew()
37 37
{
38 38
  #if defined (SAFE_ARRAYS)
39 39
    if (!gradient_structure::instances)
......
44 44
      ad_exit(1);
45 45
    }
46 46
  #endif
47
  dlink* tmp = gradient_structure::GRAD_LIST->last_remove();
48
  if (tmp == nullptr)
47 49
  {
48
    dlink * tmp;
49
    tmp = gradient_structure::GRAD_LIST->last_remove();
50
    if (!tmp)
51
    {
52
      tmp=gradient_structure::GRAD_LIST->create();
53
    }
54

  
55
    //  cout << "In gradnew the address of the double * ptr is "
56
    //       << _farptr_tolong(tmp) << "\n"; 
57

  
58
    return (double_and_int *) tmp;
50
    tmp = gradient_structure::GRAD_LIST->create();
59 51
  }
52
  return (double_and_int*)tmp;
60 53
}
61 54

  
62 55
/**
63 56
 * Description not yet available.
64 57
 * \param
65 58
 */
66
void gradfree(dlink * v)
59
void gradfree(dlink* v)
67 60
{
68 61
  if (gradient_structure::GRAD_LIST)
69 62
  {
......
71 64
    { 
72 65
      gradient_structure::GRAD_LIST->append(v);
73 66
    }
74
    else
67
    else if (v != nullptr)
75 68
    {
76
      delete (double_and_int *) v;
77
      v=NULL;
69
      delete (double_and_int*)v;
70
      v = nullptr;
78 71
    }
79 72
  }
80 73
}
......
119 112
 */
120 113
    dvariable::dvariable()
121 114
    {
115
//cout << __FILE__ << ':' << __LINE__ << endl;
122 116
      v=gradnew();
117
      //v=nullptr;
123 118
      //(*v).nc=0;
124 119
      #ifdef SAFE_INITIALIZE
125 120
	(*v).x=0;
126 121
	gradient_structure::GRAD_STACK1->set_gradient_stack0(default_evaluation0,&((*v).x));
127 122
      #endif
123
//cout << __FILE__ << ':' << __LINE__ << endl;
128 124
    }
129 125

  
130 126
/**
......
141 137
 */
142 138
   dvariable::~dvariable()
143 139
   {
144
     gradfree( (dlink *) v );
140
     gradfree((dlink*)v);
145 141
   }
146 142

  
147 143
/**

Also available in: Unified diff