1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-11 07:17:58 +00:00

Since we will be using calloc_str to put a string into it, convert the function to calloc_strcat which does it automatically.

This commit is contained in:
Con Kolivas 2012-12-01 08:26:31 +11:00
parent 01eb807ca0
commit 0ae02c6ec4
3 changed files with 5 additions and 4 deletions

View File

@ -2308,8 +2308,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
flip80(data, work->data); flip80(data, work->data);
header = bin2hex(data, 80); header = bin2hex(data, 80);
gbt_block = calloc_str(header); gbt_block = calloc_strcat(header);
sprintf(gbt_block, "%s", header);
free(header); free(header);
if (work->gbt_txns < 0xfd) { if (work->gbt_txns < 0xfd) {

4
util.c
View File

@ -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 */ /* 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); size_t len = strlen(s);
void *ptr = NULL; void *ptr = NULL;
@ -1493,6 +1493,8 @@ void *calloc_str(char *s)
ptr = calloc(len, 1); ptr = calloc(len, 1);
if (unlikely(!ptr)) if (unlikely(!ptr))
quit(1, "Failed to calloc ptr in calloc_str"); quit(1, "Failed to calloc ptr in calloc_str");
sprintf(ptr, "%s", s);
out: out:
return ptr; return ptr;
} }

2
util.h
View File

@ -52,7 +52,7 @@ bool extract_sockaddr(struct pool *pool, char *url);
bool auth_stratum(struct pool *pool); bool auth_stratum(struct pool *pool);
bool initiate_stratum(struct pool *pool); bool initiate_stratum(struct pool *pool);
void dev_error(struct cgpu_info *dev, enum dev_reason reason); 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); void *realloc_strcat(char *ptr, char *s);
#endif /* __UTIL_H__ */ #endif /* __UTIL_H__ */