From 6cf09afb0adb705faba90bda8302f1d86c285d4f Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Tue, 13 Mar 2012 11:35:09 -0700 Subject: [PATCH] C++: cast result of malloc --- libthreads.c | 2 +- model.c | 2 +- schedule.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libthreads.c b/libthreads.c index 8dd05d1..dbaf9e9 100644 --- a/libthreads.c +++ b/libthreads.c @@ -156,7 +156,7 @@ int main() model_checker_init(); - main_thread = malloc(sizeof(struct thread)); + main_thread = (struct thread *)malloc(sizeof(*main_thread)); create_initial_thread(main_thread); model_checker_add_system_thread(main_thread); diff --git a/model.c b/model.c index ff466ee..a8a6936 100644 --- a/model.c +++ b/model.c @@ -12,7 +12,7 @@ void model_checker_add_system_thread(struct thread *t) void model_checker_init(void) { - model = malloc(sizeof(*model)); + model = (struct model_checker *)malloc(sizeof(*model)); memset(model, 0, sizeof(*model)); /* First thread created (system_thread) will have id 1 */ diff --git a/schedule.c b/schedule.c index 3b4d57c..290bdf7 100644 --- a/schedule.c +++ b/schedule.c @@ -78,7 +78,7 @@ void scheduler_init(struct model_checker *mod) struct scheduler *sched; /* Initialize default scheduler */ - sched = malloc(sizeof(*sched)); + sched = (struct scheduler *)malloc(sizeof(*sched)); sched->init = NULL; sched->exit = NULL; sched->add_thread = default_add_thread; -- 2.34.1