Make allocations based on var size, not struct size - it's safer
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user