Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin committed Mar 27, 2018
1 parent d666490 commit 29d2573
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion util.c
Expand Up @@ -32,8 +32,10 @@ struct thread_q *tq_new(void)
struct thread_q *tq;

tq = (struct thread_q*) calloc(1, sizeof(*tq));
if (!tq)
if (!tq){
printf("fatal error: could not create thread queue.\n");
return NULL;
}

INIT_LIST_HEAD(&tq->q);
pthread_mutex_init(&tq->mutex, NULL);
Expand Down
15 changes: 9 additions & 6 deletions xel_miner.c
Expand Up @@ -370,7 +370,8 @@ void parse_arg(int key, char *arg)
show_usage_and_exit(1);
}
free(rpc_url);
rpc_url = strdupcs(arg);
rpc_url = (char*)malloc(strlen(arg) + 20);
sprintf(rpc_url, "%s", arg);
}
else {
if (*ap == '\0' || *ap == '/') {
Expand All @@ -379,13 +380,14 @@ void parse_arg(int key, char *arg)
show_usage_and_exit(1);
}
free(rpc_url);
rpc_url = (char*)malloc(strlen(ap) + 8);
rpc_url = (char*)malloc(strlen(ap) + 20);
sprintf(rpc_url, "http://%s", ap);
}

if (!nm) {
rpc_url = realloc(rpc_url, strlen(rpc_url) + 5);
sprintf(rpc_url, "%s/nxt", rpc_url);
char tmp[strlen(ap) + 20];
sprintf(tmp, "%s/nxt", rpc_url);
memcpy(rpc_url, tmp, strlen(ap) + 20);
}

break;
Expand Down Expand Up @@ -2509,6 +2511,8 @@ static void *cpu_miner_thread(void *userdata) {
}

out:
if (inst)
free_library(inst);
if (inst) free(inst);
if (vm_m) free(vm_m);
if (vm_i) free(vm_i);
Expand Down Expand Up @@ -3338,8 +3342,7 @@ int main(int argc, char **argv) {
free_up();
return 1;
}

thr_info = (struct thr_info*) calloc(opt_n_threads + 3, sizeof(*thr));
thr_info = (struct thr_info*) calloc(opt_n_threads + 3, sizeof(struct thr_info));
if (!thr_info){
free_up();
return 1;
Expand Down

0 comments on commit 29d2573

Please sign in to comment.