diff --git a/agent/agent.c b/agent/agent.c index e7e16b9..d2e97f7 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -64,7 +64,7 @@ int main(int count, char *strings[]) } printf("Connected with %s encryption\n", SSL_get_cipher(ssl)); show_certs(ssl); - if (!(args = (struct job_args*)calloc(1, sizeof(struct job_args) * MAX_AGENT_JOBS))) { + if (!(args = calloc(1, sizeof(*args) * MAX_AGENT_JOBS))) { fprintf( stderr, "Failed to calloc() %d bytes for job_args! Exiting...\n", (int)sizeof(struct job_args) * MAX_AGENT_JOBS ); @@ -74,7 +74,7 @@ int main(int count, char *strings[]) SSL_CTX_free(ctx); _exit(EXIT_FAILURE); } - if (!(job_thread = (pthread_t*)calloc(1, sizeof(pthread_t) * MAX_AGENT_JOBS))) { + if (!(job_thread = calloc(1, sizeof(*job_thread) * MAX_AGENT_JOBS))) { fprintf( stderr, "Failed to calloc() %d bytes for job_threads! Exiting...\n", (int)sizeof(pthread_t) * MAX_AGENT_JOBS ); diff --git a/agent_pool.c b/agent_pool.c index b0a4a5b..0deed22 100644 --- a/agent_pool.c +++ b/agent_pool.c @@ -110,10 +110,9 @@ void *agent_pool(void *args) struct pool_data *pool = args; pthread_mutex_t mutex; pthread_attr_t attr; - pthread_t *agent_thread = - (pthread_t *)malloc(pool->size * sizeof(pthread_t)); + pthread_t *agent_thread = malloc(pool->size * sizeof(*agent_thread)); struct agent_args *agent_struct = - malloc(pool->size * sizeof(struct agent_args)); + malloc(pool->size * sizeof(*agent_struct)); int i; memset(agent_thread, 0, sizeof(pthread_t) * pool->size); diff --git a/client_pool.c b/client_pool.c index 89e1381..589c4a0 100644 --- a/client_pool.c +++ b/client_pool.c @@ -85,9 +85,9 @@ void *client_pool(void *args) struct pool_data *pool = args; pthread_mutex_t mutex; pthread_attr_t attr; - pthread_t *client_thread = (pthread_t *)malloc(pool->size * sizeof(pthread_t)); + pthread_t *client_thread = malloc(pool->size * sizeof(*client_thread)); struct client_args *client_struct = - (struct client_args *)malloc(pool->size * sizeof(struct client_args)); + malloc(pool->size * sizeof(*client_struct)); int i; memset(client_thread, 0, sizeof(pthread_t) * pool->size); diff --git a/job_queue.c b/job_queue.c index 2a8f467..3b403c7 100644 --- a/job_queue.c +++ b/job_queue.c @@ -12,7 +12,7 @@ int start_msg_queue(void) for (i = 0; i < total_queues; i++) { if (slot[i] == NULL) { - slot[i] = (struct msg_t *)calloc(100, sizeof(struct msg_t)); + slot[i] = calloc(100, sizeof(**slot)); if (slot[i] == NULL) return -1; return i; @@ -28,7 +28,7 @@ void free_queue(int id) int start_job_queue(int poolsize) { - slot = (struct msg_t **)calloc(poolsize, sizeof(struct msg_t *)); + slot = calloc(poolsize, sizeof(*slot)); if (slot == NULL) return -1; total_queues = poolsize;