@@ -45,21 +45,14 @@ static void environment_init_threaded(environment_t* env, int num_workers) {
45
45
#if !defined(LF_SINGLE_THREADED )
46
46
env -> num_workers = num_workers ;
47
47
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 );
49
49
env -> barrier .requestors = 0 ;
50
50
env -> barrier .horizon = FOREVER_TAG ;
51
51
52
52
// 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 );
63
56
64
57
#endif
65
58
}
@@ -84,16 +77,16 @@ static void environment_init_modes(environment_t* env, int num_modes, int num_st
84
77
#ifdef MODAL_REACTORS
85
78
if (num_modes > 0 ) {
86
79
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 );
88
81
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 );
90
83
modes -> modal_reactor_states_size = num_modes ;
91
84
modes -> triggered_reactions_request = 0 ;
92
85
93
86
modes -> state_resets_size = num_state_resets ;
94
87
if (modes -> state_resets_size > 0 ) {
95
88
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 );
97
90
} else {
98
91
modes -> state_resets = NULL ;
99
92
}
@@ -113,10 +106,11 @@ static void environment_init_federated(environment_t* env, int num_is_present_fi
113
106
#ifdef FEDERATED_DECENTRALIZED
114
107
if (num_is_present_fields > 0 ) {
115
108
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 );
117
110
env -> _lf_intended_tag_fields_size = num_is_present_fields ;
118
111
} else {
119
- env -> _lf_intended_tag_fields_size = NULL ;
112
+ env -> _lf_intended_tag_fields = NULL ;
113
+ env -> _lf_intended_tag_fields_size = 0 ;
120
114
}
121
115
#endif
122
116
}
@@ -198,7 +192,7 @@ int environment_init(
198
192
) {
199
193
200
194
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 );
202
196
strcpy (env -> name , name );
203
197
204
198
env -> id = id ;
@@ -207,31 +201,31 @@ int environment_init(
207
201
env -> timer_triggers_size = num_timers ;
208
202
if (env -> timer_triggers_size > 0 ) {
209
203
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 );
211
205
} else {
212
206
env -> timer_triggers = NULL ;
213
207
}
214
208
215
209
env -> startup_reactions_size = num_startup_reactions ;
216
210
if (env -> startup_reactions_size > 0 ) {
217
211
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 );
219
213
} else {
220
214
env -> startup_reactions = NULL ;
221
215
}
222
216
223
217
env -> shutdown_reactions_size = num_shutdown_reactions ;
224
218
if (env -> shutdown_reactions_size > 0 ) {
225
219
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 );
227
221
} else {
228
222
env -> shutdown_reactions = NULL ;
229
223
}
230
224
231
225
env -> reset_reactions_size = num_reset_reactions ;
232
226
if (env -> reset_reactions_size > 0 ) {
233
227
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 );
235
229
} else {
236
230
env -> reset_reactions = NULL ;
237
231
}
@@ -241,9 +235,9 @@ int environment_init(
241
235
242
236
if (env -> is_present_fields_size > 0 ) {
243
237
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 );
245
239
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 );
247
241
} else {
248
242
env -> is_present_fields = NULL ;
249
243
env -> is_present_fields_abbreviated = NULL ;
0 commit comments