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