mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 16:44:49 +01:00
Fixed leaks:
SELECTED_OUTPUT redefinition, read_selected_output zero in cl1mp.cpp leak in eq_frac Basic function if file open failed, leaked ofstream pointer Don't close files in class_main.cpp cvdense and cvode changed to allow use of MS memory debugging git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@8815 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
e4229340b0
commit
b93eda4643
@ -3452,6 +3452,7 @@ factor(struct LOC_exec * LINK)
|
||||
if (LINK->t->kind != tokvar || elt_varrec->stringvar != 1)
|
||||
snerr(": Cannot find element string variable");
|
||||
free_dim_stringvar(elt_varrec);
|
||||
*elt_varrec->UU.U1.sval = (char *) PhreeqcPtr->free_check_null(*elt_varrec->UU.U1.sval);
|
||||
|
||||
// right parenthesis
|
||||
LINK->t = LINK->t->next;
|
||||
|
||||
@ -54,6 +54,10 @@ ofstream_open(std::ostream **os, const char *file_name, std::ios_base::openmode
|
||||
*os = ofs;
|
||||
return true;
|
||||
}
|
||||
if (ofs)
|
||||
{
|
||||
delete ofs;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -1109,6 +1109,7 @@ cl1mp(int k, int l, int m, int n,
|
||||
mpf_clear(cu[i]);
|
||||
}
|
||||
cu = (mpf_t *) free_check_null(cu);
|
||||
mpf_clear(zero);
|
||||
mpf_clear(dummy);
|
||||
mpf_clear(dummy1);
|
||||
mpf_clear(sum);
|
||||
|
||||
@ -31,12 +31,21 @@ main(int argc, char *argv[])
|
||||
* heap's linked list - This will allow us to catch any
|
||||
* inadvertent use of freed memory
|
||||
*/
|
||||
#ifdef SKIP
|
||||
// Send messages (leaks) to stderr
|
||||
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR );
|
||||
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
|
||||
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
|
||||
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
|
||||
#endif
|
||||
tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
|
||||
//tmpDbgFlag |= _CRTDBG_DELAY_FREE_MEM_DF;
|
||||
tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF;
|
||||
///tmpDbgFlag |= _CRTDBG_CHECK_ALWAYS_DF;
|
||||
_CrtSetDbgFlag(tmpDbgFlag);
|
||||
//_crtBreakAlloc = 329203;
|
||||
//_crtBreakAlloc = 31195;
|
||||
#endif
|
||||
#ifdef SKIP
|
||||
//Set the x86 floating-point control word according to what
|
||||
@ -236,7 +245,6 @@ main_method(int argc, char *argv[])
|
||||
{
|
||||
return errors;
|
||||
}
|
||||
output_close();
|
||||
return 0;
|
||||
}
|
||||
#endif //TEST_COPY
|
||||
|
||||
@ -72,7 +72,9 @@
|
||||
|
||||
|
||||
#include "Phreeqc.h"
|
||||
#if !defined(WIN32_MEMORY_DEBUG)
|
||||
#define malloc PHRQ_malloc
|
||||
#endif
|
||||
#define MACHENV machEnv->phreeqc_ptr->
|
||||
#define CVMEM cv_mem->cv_machenv->phreeqc_ptr->
|
||||
#define MACHENV_MALLOC MACHENV
|
||||
@ -306,7 +308,11 @@ CVDense(void *cvode_mem, CVDenseJacFn djac, void *jac_data)
|
||||
lfree = CVDenseFree;
|
||||
|
||||
/* Get memory for CVDenseMemRec */
|
||||
#if defined(WIN32_MEMORY_DEBUG)
|
||||
lmem = cvdense_mem = (CVDenseMem) malloc(sizeof(CVDenseMemRec));
|
||||
#else
|
||||
lmem = cvdense_mem = (CVDenseMem) CVMEM_MALLOC malloc(sizeof(CVDenseMemRec));
|
||||
#endif
|
||||
if (cvdense_mem == NULL)
|
||||
{
|
||||
CVMEM warning_msg( MSG_MEM_FAIL);
|
||||
|
||||
@ -72,7 +72,9 @@
|
||||
#include "sundialsmath.h"
|
||||
|
||||
#include "Phreeqc.h"
|
||||
#if !defined(WIN32_MEMORY_DEBUG)
|
||||
#define malloc MACHENV_MALLOC PHRQ_malloc
|
||||
#endif
|
||||
#define MACHENV machEnv->phreeqc_ptr->
|
||||
#define CVMEM cv_mem->cv_machenv->phreeqc_ptr->
|
||||
#define MACHENV_MALLOC MACHENV
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user