Revision 7ff3c017

View differences:

src/sim/cdynamicexpression.cc
264 264
static const int stksize = 20;
265 265

  
266 266
// we have a static stack to avoid new[] and call to Value ctor stksize times
267
static cDynamicExpression::Value _stk[stksize];
268
static bool _stkinuse = false;
267
static __thread cDynamicExpression::Value* _stk = NULL;
268
static __thread bool _stkinuse = false;
269 269

  
270 270
cDynamicExpression::Value cDynamicExpression::evaluate(cComponent *context) const
271 271
{
272
	if(!_stk) _stk=new cDynamicExpression::Value[stksize];
272 273
    // use static _stk[] if possible, or allocate another one if that's in use.
273
    // Note: this will be reentrant but NOT thread safe
274
    // Note: this will be reentrant and thread safe (due to threadlocal global vars)
274 275
    Value *stk;
275 276
    if (_stkinuse)
276 277
        stk = new Value[stksize];

Also available in: Unified diff