From: Brian Norris Date: Tue, 13 Mar 2012 18:35:09 +0000 (-0700) Subject: C++: cast result of malloc X-Git-Tag: pldi2013~585 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=6cf09afb0adb705faba90bda8302f1d86c285d4f;p=model-checker.git C++: cast result of malloc --- 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;