Skip to content

Commit

Permalink
driver-ztex: changed two pairs of malloc()/memset() to calloc()
Browse files Browse the repository at this point in the history
  • Loading branch information
denis2342 committed Dec 6, 2012
1 parent b48b2cc commit e59f668
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions driver-ztex.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,19 @@ static int64_t ztex_scanhash(struct thr_info *thr, struct work *work,

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) {
applog(LOG_ERR, "%s: failed to allocate lastnonce[%d]", ztex->repr, ztex->numNonces);
return -1;
}
memset(lastnonce, 0, sizeof(uint32_t)*ztex->numNonces);

/* Add an extra slot for detecting dupes that lie around */
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) {
applog(LOG_ERR, "%s: failed to allocate backlog[%d]", ztex->repr, backlog_max);
return -1;
}
memset(backlog, 0, sizeof(uint32_t) * backlog_max);

overflow = false;

Expand Down

0 comments on commit e59f668

Please sign in to comment.