Skip to content

Commit

Permalink
Merge pull request #787 from gtrensch/fix-644-bad-alloc
Browse files Browse the repository at this point in the history
Fix #644: bad_alloc exception
  • Loading branch information
terhorstd authored Aug 7, 2017
2 parents d3f2dcd + 8e2a527 commit 7e25df7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions nestkernel/nest_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ class Time
// delay: steps, signed long
// double: milliseconds (double!)

friend class TimeConverter;

/////////////////////////////////////////////////////////////
// Range: Limits & conversion factors for different types
/////////////////////////////////////////////////////////////
Expand Down
8 changes: 8 additions & 0 deletions nestkernel/nest_timeconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@ TimeConverter::TimeConverter()
Time
TimeConverter::from_old_steps( long s_old ) const
{
if ( s_old == Time::LIM_NEG_INF.steps || s_old == Time::LIM_POS_INF.steps )
{
return Time( Time::step( s_old ) );
}
double ms = s_old * OLD_TICS_PER_STEP / OLD_TICS_PER_MS;
return Time::ms( ms );
}

Time
TimeConverter::from_old_tics( tic_t t_old ) const
{
if ( t_old == Time::LIM_NEG_INF.tics || t_old == Time::LIM_POS_INF.tics )
{
return Time( Time::tic( t_old ) );
}
double ms = t_old / OLD_TICS_PER_MS;
return Time::ms( ms );
}
Expand Down
2 changes: 1 addition & 1 deletion nestkernel/nest_timeconverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace nest
class Time;
/**
* Class to convert times from one representation to another.
* Createing an object of TimeCOnverter at a current time representation
* Creating an object of TimeConverter at a current time representation
* saves the current values of TICS_PER_MS and TICS_PER_STEP.
* After having changed the time representation,
* the members from_old_steps and from_old_tics can be used
Expand Down

0 comments on commit 7e25df7

Please sign in to comment.