diff options
author | Stinson Linden <stinson@lindenlab.com> | 2014-04-28 19:18:47 +0100 |
---|---|---|
committer | Stinson Linden <stinson@lindenlab.com> | 2014-04-28 19:18:47 +0100 |
commit | 37d620463b6f6d0ec932f1660f314268bafa229a (patch) | |
tree | 04264ab005d52b4107b4b33ad83adf9f4e3021ba /indra/llcommon/llerror.cpp | |
parent | b31bfdba37398e3100e8e209d407cea6065ce52a (diff) |
MAINT-4009: Cleaning up the error callstacks memory before app quit.
Diffstat (limited to 'indra/llcommon/llerror.cpp')
-rwxr-xr-x | indra/llcommon/llerror.cpp | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index a3053617d3..4f721fabdf 100755 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -1357,15 +1357,9 @@ namespace LLError #endif //static - void LLCallStacks::push(const char* function, const int line) + void LLCallStacks::allocateStackBuffer() { - CallStacksLogLock lock; - if (!lock.ok()) - { - return; - } - - if(!sBuffer) + if(sBuffer == NULL) { sBuffer = new char*[512] ; sBuffer[0] = new char[512 * 128] ; @@ -1375,6 +1369,31 @@ namespace LLError } sIndex = 0 ; } + } + + void LLCallStacks::freeStackBuffer() + { + if(sBuffer != NULL) + { + delete [] sBuffer[0] ; + delete [] sBuffer ; + sBuffer = NULL ; + } + } + + //static + void LLCallStacks::push(const char* function, const int line) + { + CallStacksLogLock lock; + if (!lock.ok()) + { + return; + } + + if(sBuffer == NULL) + { + allocateStackBuffer(); + } if(sIndex > 511) { @@ -1406,15 +1425,9 @@ namespace LLError return; } - if(!sBuffer) + if(sBuffer == NULL) { - sBuffer = new char*[512] ; - sBuffer[0] = new char[512 * 128] ; - for(S32 i = 1 ; i < 512 ; i++) - { - sBuffer[i] = sBuffer[i-1] + 128 ; - } - sIndex = 0 ; + allocateStackBuffer(); } if(sIndex > 511) @@ -1445,11 +1458,9 @@ namespace LLError LL_INFOS() << " *************** END OF LL CALL STACKS *************** " << LL_ENDL; } - if(sBuffer) + if(sBuffer != NULL) { - delete[] sBuffer[0] ; - delete[] sBuffer ; - sBuffer = NULL ; + freeStackBuffer(); } } @@ -1459,5 +1470,10 @@ namespace LLError sIndex = 0 ; } + //static + void LLCallStacks::cleanup() + { + freeStackBuffer(); + } } |