Browse Source

driver-ztex: changed two pairs of malloc()/memset() to calloc()

nfactor-troky
Denis Ahrens 12 years ago
parent
commit
e59f668191
  1. 6
      driver-ztex.c

6
driver-ztex.c

@ -222,21 +222,19 @@ static int64_t ztex_scanhash(struct thr_info *thr, struct work *work,
applog(LOG_DEBUG, "%s: sent hashdata", ztex->repr); applog(LOG_DEBUG, "%s: sent hashdata", ztex->repr);
lastnonce = malloc(sizeof(uint32_t)*ztex->numNonces); lastnonce = calloc(1, sizeof(uint32_t)*ztex->numNonces);
if (lastnonce == NULL) { if (lastnonce == NULL) {
applog(LOG_ERR, "%s: failed to allocate lastnonce[%d]", ztex->repr, ztex->numNonces); applog(LOG_ERR, "%s: failed to allocate lastnonce[%d]", ztex->repr, ztex->numNonces);
return -1; return -1;
} }
memset(lastnonce, 0, sizeof(uint32_t)*ztex->numNonces);
/* Add an extra slot for detecting dupes that lie around */ /* Add an extra slot for detecting dupes that lie around */
backlog_max = ztex->numNonces * (2 + ztex->extraSolutions); backlog_max = ztex->numNonces * (2 + ztex->extraSolutions);
backlog = malloc(sizeof(uint32_t) * backlog_max); backlog = calloc(1, sizeof(uint32_t) * backlog_max);
if (backlog == NULL) { if (backlog == NULL) {
applog(LOG_ERR, "%s: failed to allocate backlog[%d]", ztex->repr, backlog_max); applog(LOG_ERR, "%s: failed to allocate backlog[%d]", ztex->repr, backlog_max);
return -1; return -1;
} }
memset(backlog, 0, sizeof(uint32_t) * backlog_max);
overflow = false; overflow = false;

Loading…
Cancel
Save