From: Mathieu Desnoyers Date: Fri, 31 Dec 2010 17:50:59 +0000 (-0500) Subject: urcu-defer: handle malloc error value X-Git-Tag: v0.5.3~12 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7fdbbd612a9364fa31827ab46e539b9905c13f44;p=urcu.git urcu-defer: handle malloc error value Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-defer.c b/urcu-defer.c index 28bb18c..3f596ae 100644 --- a/urcu-defer.c +++ b/urcu-defer.c @@ -339,13 +339,15 @@ static void stop_defer_thread(void) assert(!ret); } -void rcu_defer_register_thread(void) +int rcu_defer_register_thread(void) { int was_empty; assert(defer_queue.last_head == 0); assert(defer_queue.q == NULL); defer_queue.q = malloc(sizeof(void *) * DEFER_QUEUE_SIZE); + if (!defer_queue.q) + return -ENOMEM; mutex_lock(&defer_thread_mutex); mutex_lock(&rcu_defer_mutex); @@ -356,6 +358,7 @@ void rcu_defer_register_thread(void) if (was_empty) start_defer_thread(); mutex_unlock(&defer_thread_mutex); + return 0; } void rcu_defer_unregister_thread(void) diff --git a/urcu-defer.h b/urcu-defer.h index e161616..2019e13 100644 --- a/urcu-defer.h +++ b/urcu-defer.h @@ -63,7 +63,7 @@ extern void defer_rcu(void (*fct)(void *p), void *p); /* * Thread registration for reclamation. */ -extern void rcu_defer_register_thread(void); +extern int rcu_defer_register_thread(void); extern void rcu_defer_unregister_thread(void); extern void rcu_defer_barrier(void); extern void rcu_defer_barrier_thread(void);