Author: pfg Date: Tue May 31 23:25:11 2016 New Revision: 1746363 URL: http://svn.apache.org/viewvc?rev=1746363&view=rev Log: RAND(): Destroy the random pool after seeding.
We are using rtl_random() only for seeding, we can save some memory here. Modified: openoffice/trunk/main/sc/source/core/tool/interpr1.cxx Modified: openoffice/trunk/main/sc/source/core/tool/interpr1.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sc/source/core/tool/interpr1.cxx?rev=1746363&r1=1746362&r2=1746363&view=diff ============================================================================== --- openoffice/trunk/main/sc/source/core/tool/interpr1.cxx (original) +++ openoffice/trunk/main/sc/source/core/tool/interpr1.cxx Tue May 31 23:25:11 2016 @@ -1679,15 +1679,16 @@ void ScInterpreter::ScRandom() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "pfg", "ScInterpreter::ScRandom" ); - static rtlRandomPool aPool = rtl_random_createPool(); static sal_Bool SqSeeded = sal_False; static sal_uInt32 ScCNG, ScXS = 362436069; // Seeding for the PRNG if (SqSeeded == sal_False) { + rtlRandomPool aPool = rtl_random_createPool(); rtl_random_getBytes(aPool, &ScCNG, sizeof(ScCNG)); rtl_random_getBytes(aPool, &nScRandomQ, sizeof(nScRandomQ[0]) * SCRANDOMQ_SIZE); + rtl_random_destroyPool(aPool); SqSeeded = sal_True; } PushDouble(static_cast<double>(KISS) / SAL_MAX_UINT32);