Remove all static work structs, using the make and free functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff --git a/cgminer.c b/cgminer.c
index fc2090d..04da779 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4737,14 +4737,13 @@ static void *stratum_thread(void *userdata)
applog(LOG_INFO, "Unknown stratum msg: %s", s);
free(s);
if (pool->swork.clean) {
- struct work work;
- memset(&work, 0, sizeof(work));
+ struct work *work = make_work();
/* Generate a single work item to update the current
* block database */
pool->swork.clean = false;
- gen_stratum_work(pool, &work);
- if (test_work_current(&work)) {
+ gen_stratum_work(pool, work);
+ if (test_work_current(work)) {
/* Only accept a work restart if this stratum
* connection is from the current pool */
if (pool == current_pool()) {
@@ -4753,8 +4752,8 @@ static void *stratum_thread(void *userdata)
}
} else
applog(LOG_NOTICE, "Stratum from pool %d detected new block", pool->pool_no);
+ free_work(work);
}
-
}
out:
@@ -5936,8 +5935,8 @@ static bool pool_getswork(struct pool *pool)
gettimeofday(&tv_getwork_reply, NULL);
if (val) {
- struct work work;
- bool rc = work_decode(pool, &work, val);
+ struct work *work = make_work();
+ bool rc = work_decode(pool, work, val);
if (rc) {
applog(LOG_DEBUG, "Successfully retrieved and deciphered work from pool %u %s",
@@ -5949,6 +5948,7 @@ static bool pool_getswork(struct pool *pool)
pool->pool_no, pool->rpc_url);
}
json_decref(val);
+ free_work(work);
} else {
applog(LOG_DEBUG, "FAILED to retrieve pool_getswork work from pool %u %s",
pool->pool_no, pool->rpc_url);