From: <tf...@us...> - 2008-04-30 01:19:28
|
Revision: 244 http://personalrobots.svn.sourceforge.net/personalrobots/?rev=244&view=rev Author: tfoote Date: 2008-04-29 18:19:33 -0700 (Tue, 29 Apr 2008) Log Message: ----------- Merging my stuff across. ticket:20 r1040@zug (orig r243): tfoote | 2008-04-29 18:17:58 -0700 adding a max length to the linked list to prevent unbounded memory usage Modified Paths: -------------- pkg/branches/rosbus/unported/libTF/include/libTF/Quaternion3D.h pkg/branches/rosbus/unported/libTF/src/simple/Quaternion3D.cpp Property Changed: ---------------- pkg/branches/rosbus/unported/libTF/ Property changes on: pkg/branches/rosbus/unported/libTF ___________________________________________________________________ Name: svk:merge - 5d0af4bb-b190-461e-89ab-f239232fb17e:/zug/libtf:633 f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/trunk/libTF:239 + 5d0af4bb-b190-461e-89ab-f239232fb17e:/zug/libtf:633 f5854215-dd47-0410-b2c4-cdd35faa7885:/pkg/trunk/libTF:243 Modified: pkg/branches/rosbus/unported/libTF/include/libTF/Quaternion3D.h =================================================================== --- pkg/branches/rosbus/unported/libTF/include/libTF/Quaternion3D.h 2008-04-30 01:17:58 UTC (rev 243) +++ pkg/branches/rosbus/unported/libTF/include/libTF/Quaternion3D.h 2008-04-30 01:19:33 UTC (rev 244) @@ -53,6 +53,7 @@ public: static const int MIN_INTERPOLATION_DISTANCE = 5; //Number of nano-seconds to not interpolate below. + static const unsigned int MAX_LENGTH_LINKED_LIST = 1000000; // Maximum length of linked list, to make sure not to be able to use unlimited memory. // Storage class class Quaternion3DStorage { @@ -155,8 +156,8 @@ data_LL* first; data_LL* last; + unsigned int list_length; - }; Modified: pkg/branches/rosbus/unported/libTF/src/simple/Quaternion3D.cpp =================================================================== --- pkg/branches/rosbus/unported/libTF/src/simple/Quaternion3D.cpp 2008-04-30 01:17:58 UTC (rev 243) +++ pkg/branches/rosbus/unported/libTF/src/simple/Quaternion3D.cpp 2008-04-30 01:19:33 UTC (rev 244) @@ -42,7 +42,8 @@ Quaternion3D::Quaternion3D(unsigned long long max_cache_time): max_storage_time(max_cache_time), first(NULL), - last(NULL) + last(NULL), + list_length(0) { pthread_mutex_init( &linked_list_mutex, NULL); @@ -355,7 +356,6 @@ void Quaternion3D::insertNode(const Quaternion3DStorage & new_val) { - data_LL* p_current; data_LL* p_old; @@ -417,6 +417,10 @@ } + + // Record that we have increased the length of th elist + list_length ++; + }; void Quaternion3D::pruneList() @@ -432,7 +436,7 @@ //While time stamps too old - while (p_current->data.time + max_storage_time < current_time) + while (p_current->data.time + max_storage_time < current_time || list_length > MAX_LENGTH_LINKED_LIST) { // cout << "Age of node " << (double)(-p_current->data.time + current_time)/1000000.0 << endl; // Make sure that there's at least two elements in the list @@ -446,6 +450,7 @@ delete p_current; p_current = last; // cout << " Pruning Node" << endl; + list_length--; } else break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |