stratum: attempt to reduce memory leaks

This commit is contained in:
Tanguy Pruvot 2016-01-20 14:49:58 +01:00
parent 31e908531a
commit fa47829c4e
3 changed files with 10 additions and 4 deletions

View file

@ -115,7 +115,6 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
{
coind_error(coind, "getblocktemplate result");
json_value_free(json);
return NULL;
}
@ -124,7 +123,6 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
{
coind_error(coind, "getblocktemplate transactions");
json_value_free(json);
return NULL;
}
@ -133,7 +131,6 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
{
coind_error(coind, "getblocktemplate coinbaseaux");
json_value_free(json);
return NULL;
}
@ -204,6 +201,7 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
templ->txmerkles[0] = 0;
templ->txcount = txhashes.size();
templ->txsteps = merkle_steps(txhashes);
txhashes.clear();
vector<string>::const_iterator i;
for(i = templ->txsteps.begin(); i != templ->txsteps.end(); ++i)
@ -251,6 +249,10 @@ void coind_create_job(YAAMP_COIND *coind, bool force)
strcmp(templ->coinb2, job_last->templ->coinb2) == 0)
{
// debuglog("coind_create_job %s %d same template %x \n", coind->name, coind->height, coind->job->id);
if (templ->txcount) {
templ->txsteps.clear();
templ->txdata.clear();
}
delete templ;
CommonUnlock(&coind->mutex);

View file

@ -73,6 +73,10 @@ public:
inline void job_delete(YAAMP_OBJECT *object)
{
YAAMP_JOB *job = (YAAMP_JOB *)object;
if (job->templ->txcount) {
job->templ->txsteps.clear();
job->templ->txdata.clear();
}
delete job->templ;
delete job;
}

View file

@ -53,7 +53,7 @@ string merkle_with_first(vector<string> steps, string f)
sha256_double_hash_hex(bin, out, YAAMP_HASHLEN_BIN*2);
f = out;
}
}
return f;
}