From 0ae02c6ec4351d1def5f2cffa0e0a86290afab70 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 1 Dec 2012 08:26:31 +1100 Subject: [PATCH] Since we will be using calloc_str to put a string into it, convert the function to calloc_strcat which does it automatically. --- cgminer.c | 3 +-- util.c | 4 +++- util.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cgminer.c b/cgminer.c index cd2c12ad..8cbc01eb 100644 --- a/cgminer.c +++ b/cgminer.c @@ -2308,8 +2308,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit) flip80(data, work->data); header = bin2hex(data, 80); - gbt_block = calloc_str(header); - sprintf(gbt_block, "%s", header); + gbt_block = calloc_strcat(header); free(header); if (work->gbt_txns < 0xfd) { diff --git a/util.c b/util.c index 1dbeb0d0..8f17955f 100644 --- a/util.c +++ b/util.c @@ -1479,7 +1479,7 @@ void dev_error(struct cgpu_info *dev, enum dev_reason reason) } /* Calloc enough memory to fit string s, rounding up to 4 byte alignment */ -void *calloc_str(char *s) +void *calloc_strcat(char *s) { size_t len = strlen(s); void *ptr = NULL; @@ -1493,6 +1493,8 @@ void *calloc_str(char *s) ptr = calloc(len, 1); if (unlikely(!ptr)) quit(1, "Failed to calloc ptr in calloc_str"); + + sprintf(ptr, "%s", s); out: return ptr; } diff --git a/util.h b/util.h index cb41f6ca..b28618c2 100644 --- a/util.h +++ b/util.h @@ -52,7 +52,7 @@ bool extract_sockaddr(struct pool *pool, char *url); bool auth_stratum(struct pool *pool); bool initiate_stratum(struct pool *pool); void dev_error(struct cgpu_info *dev, enum dev_reason reason); -void *calloc_str(char *s); +void *calloc_strcat(char *s); void *realloc_strcat(char *ptr, char *s); #endif /* __UTIL_H__ */