@@ -45,21 +45,14 @@ static void environment_init_threaded(environment_t* env, int num_workers) {
4545#if !defined(LF_SINGLE_THREADED )
4646 env -> num_workers = num_workers ;
4747 env -> thread_ids = (lf_thread_t * )calloc (num_workers , sizeof (lf_thread_t ));
48- LF_ASSERT (env -> thread_ids , "Out of memory" );
48+ LF_ASSERT_NON_NULL (env -> thread_ids );
4949 env -> barrier .requestors = 0 ;
5050 env -> barrier .horizon = FOREVER_TAG ;
5151
5252 // Initialize synchronization objects.
53- if (lf_mutex_init (& env -> mutex ) != 0 ) {
54- lf_print_error_and_exit ("Could not initialize environment mutex" );
55- }
56- if (lf_cond_init (& env -> event_q_changed , & env -> mutex ) != 0 ) {
57- lf_print_error_and_exit ("Could not initialize environment event queue condition variable" );
58- }
59- if (lf_cond_init (& env -> global_tag_barrier_requestors_reached_zero , & env -> mutex )) {
60- lf_print_error_and_exit ("Could not initialize environment tag barrier condition variable" );
61- }
62-
53+ LF_MUTEX_INIT (& env -> mutex );
54+ LF_COND_INIT (& env -> event_q_changed , & env -> mutex );
55+ LF_COND_INIT (& env -> global_tag_barrier_requestors_reached_zero , & env -> mutex );
6356
6457#endif
6558}
@@ -84,16 +77,16 @@ static void environment_init_modes(environment_t* env, int num_modes, int num_st
8477#ifdef MODAL_REACTORS
8578 if (num_modes > 0 ) {
8679 mode_environment_t * modes = (mode_environment_t * ) calloc (1 , sizeof (mode_environment_t ));
87- LF_ASSERT (modes , "Out of memory" );
80+ LF_ASSERT_NON_NULL (modes );
8881 modes -> modal_reactor_states = (reactor_mode_state_t * * ) calloc (num_modes , sizeof (reactor_mode_state_t * ));
89- LF_ASSERT (modes -> modal_reactor_states , "Out of memory" );
82+ LF_ASSERT_NON_NULL (modes -> modal_reactor_states );
9083 modes -> modal_reactor_states_size = num_modes ;
9184 modes -> triggered_reactions_request = 0 ;
9285
9386 modes -> state_resets_size = num_state_resets ;
9487 if (modes -> state_resets_size > 0 ) {
9588 modes -> state_resets = (mode_state_variable_reset_data_t * ) calloc (modes -> state_resets_size , sizeof (mode_state_variable_reset_data_t ));
96- LF_ASSERT (modes -> state_resets , "Out of memory" );
89+ LF_ASSERT_NON_NULL (modes -> state_resets );
9790 } else {
9891 modes -> state_resets = NULL ;
9992 }
@@ -113,10 +106,11 @@ static void environment_init_federated(environment_t* env, int num_is_present_fi
113106#ifdef FEDERATED_DECENTRALIZED
114107 if (num_is_present_fields > 0 ) {
115108 env -> _lf_intended_tag_fields = (tag_t * * ) calloc (num_is_present_fields , sizeof (tag_t * ));
116- LF_ASSERT (env -> _lf_intended_tag_fields , "Out of memory" );
109+ LF_ASSERT_NON_NULL (env -> _lf_intended_tag_fields );
117110 env -> _lf_intended_tag_fields_size = num_is_present_fields ;
118111 } else {
119- env -> _lf_intended_tag_fields_size = NULL ;
112+ env -> _lf_intended_tag_fields = NULL ;
113+ env -> _lf_intended_tag_fields_size = 0 ;
120114 }
121115#endif
122116}
@@ -198,7 +192,7 @@ int environment_init(
198192) {
199193
200194 env -> name = malloc (strlen (name ) + 1 ); // +1 for the null terminator
201- LF_ASSERT (env -> name , "Out of memory" );
195+ LF_ASSERT_NON_NULL (env -> name );
202196 strcpy (env -> name , name );
203197
204198 env -> id = id ;
@@ -207,31 +201,31 @@ int environment_init(
207201 env -> timer_triggers_size = num_timers ;
208202 if (env -> timer_triggers_size > 0 ) {
209203 env -> timer_triggers = (trigger_t * * ) calloc (num_timers , sizeof (trigger_t ));
210- LF_ASSERT (env -> timer_triggers , "Out of memory" );
204+ LF_ASSERT_NON_NULL (env -> timer_triggers );
211205 } else {
212206 env -> timer_triggers = NULL ;
213207 }
214208
215209 env -> startup_reactions_size = num_startup_reactions ;
216210 if (env -> startup_reactions_size > 0 ) {
217211 env -> startup_reactions = (reaction_t * * ) calloc (num_startup_reactions , sizeof (reaction_t ));
218- LF_ASSERT (env -> startup_reactions , "Out of memory" );
212+ LF_ASSERT_NON_NULL (env -> startup_reactions );
219213 } else {
220214 env -> startup_reactions = NULL ;
221215 }
222216
223217 env -> shutdown_reactions_size = num_shutdown_reactions ;
224218 if (env -> shutdown_reactions_size > 0 ) {
225219 env -> shutdown_reactions = (reaction_t * * ) calloc (num_shutdown_reactions , sizeof (reaction_t ));
226- LF_ASSERT (env -> shutdown_reactions , "Out of memory" );
220+ LF_ASSERT_NON_NULL (env -> shutdown_reactions );
227221 } else {
228222 env -> shutdown_reactions = NULL ;
229223 }
230224
231225 env -> reset_reactions_size = num_reset_reactions ;
232226 if (env -> reset_reactions_size > 0 ) {
233227 env -> reset_reactions = (reaction_t * * ) calloc (num_reset_reactions , sizeof (reaction_t ));
234- LF_ASSERT (env -> reset_reactions , "Out of memory" );
228+ LF_ASSERT_NON_NULL (env -> reset_reactions );
235229 } else {
236230 env -> reset_reactions = NULL ;
237231 }
@@ -241,9 +235,9 @@ int environment_init(
241235
242236 if (env -> is_present_fields_size > 0 ) {
243237 env -> is_present_fields = (bool * * )calloc (num_is_present_fields , sizeof (bool * ));
244- LF_ASSERT (env -> is_present_fields , "Out of memory" );
238+ LF_ASSERT_NON_NULL (env -> is_present_fields );
245239 env -> is_present_fields_abbreviated = (bool * * )calloc (num_is_present_fields , sizeof (bool * ));
246- LF_ASSERT (env -> is_present_fields_abbreviated , "Out of memory" );
240+ LF_ASSERT_NON_NULL (env -> is_present_fields_abbreviated );
247241 } else {
248242 env -> is_present_fields = NULL ;
249243 env -> is_present_fields_abbreviated = NULL ;
0 commit comments