mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 20:44:19 +00:00
Use stack memory in test_work_current, avoiding a malloc/free cycle each time.
This commit is contained in:
parent
d3c215fda6
commit
e0c90359fd
10
cgminer.c
10
cgminer.c
@ -4006,15 +4006,15 @@ static void set_blockdiff(const struct work *work)
|
|||||||
static bool test_work_current(struct work *work)
|
static bool test_work_current(struct work *work)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
char *hexstr;
|
char hexstr[20];
|
||||||
|
|
||||||
if (work->mandatory)
|
if (work->mandatory)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* Hack to work around dud work sneaking into test */
|
/* Hack to work around dud work sneaking into test */
|
||||||
hexstr = bin2hex(work->data + 8, 18);
|
__bin2hex(hexstr, work->data + 8, 18);
|
||||||
if (!strncmp(hexstr, "000000000000000000000000000000000000", 36))
|
if (!strncmp(hexstr, "000000000000000000000000000000000000", 36))
|
||||||
goto out_free;
|
return ret;
|
||||||
|
|
||||||
/* Search to see if this block exists yet and if not, consider it a
|
/* Search to see if this block exists yet and if not, consider it a
|
||||||
* new block and set the current block details to this one */
|
* new block and set the current block details to this one */
|
||||||
@ -4049,7 +4049,7 @@ static bool test_work_current(struct work *work)
|
|||||||
applog(LOG_DEBUG, "Deleted block %d from database", deleted_block);
|
applog(LOG_DEBUG, "Deleted block %d from database", deleted_block);
|
||||||
set_curblock(hexstr, work->data);
|
set_curblock(hexstr, work->data);
|
||||||
if (unlikely(new_blocks == 1))
|
if (unlikely(new_blocks == 1))
|
||||||
goto out_free;
|
return ret;
|
||||||
|
|
||||||
work->work_block = ++work_block;
|
work->work_block = ++work_block;
|
||||||
|
|
||||||
@ -4072,8 +4072,6 @@ static bool test_work_current(struct work *work)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
work->longpoll = false;
|
work->longpoll = false;
|
||||||
out_free:
|
|
||||||
free(hexstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user