@@ -145,12 +145,12 @@ struct am_event *am_event_allocate(int id, int size) {
145145 return event ;
146146}
147147
148- static void am_event_free_unsafe (const struct am_event * * event ) {
149- if (am_event_is_static (* event )) {
148+ static void am_event_free_unsafe (const struct am_event * event ) {
149+ if (am_event_is_static (event )) {
150150 return ; /* the event is statically allocated */
151151 }
152152
153- struct am_event * e = AM_CAST (struct am_event * , * event );
153+ struct am_event * e = AM_CAST (struct am_event * , event );
154154 AM_ASSERT (e -> pool_index_plus_one <= AM_EVENT_POOLS_NUM_MAX );
155155 /*
156156 * Check if event is valid.
@@ -165,13 +165,10 @@ static void am_event_free_unsafe(const struct am_event **event) {
165165 }
166166
167167 am_onesize_free (& am_event_state_ .pools [e -> pool_index_plus_one - 1 ], e );
168-
169- * event = NULL ;
170168}
171169
172- void am_event_free (const struct am_event * * event ) {
170+ void am_event_free (const struct am_event * event ) {
173171 AM_ASSERT (event );
174- AM_ASSERT (* event ); /* double free? */
175172
176173 struct am_event_state * me = & am_event_state_ ;
177174 me -> crit_enter ();
@@ -325,7 +322,7 @@ void am_event_inc_ref_cnt(const struct am_event *event) {
325322
326323void am_event_dec_ref_cnt (const struct am_event * event ) {
327324 AM_ASSERT (event );
328- am_event_free (& event );
325+ am_event_free (event );
329326}
330327
331328int am_event_get_ref_cnt (const struct am_event * event ) {
@@ -385,9 +382,9 @@ static enum am_event_rc am_event_push_x(
385382 if (nfree <= margin ) {
386383 if (safe ) {
387384 me -> crit_exit ();
388- am_event_free (& event );
385+ am_event_free (event );
389386 } else {
390- am_event_free_unsafe (& event );
387+ am_event_free_unsafe (event );
391388 }
392389 return AM_EVENT_RC_ERR ;
393390 }
@@ -503,7 +500,7 @@ bool am_event_pop_front(
503500 return true;
504501 }
505502
506- am_event_free (& event );
503+ am_event_free (event );
507504
508505 return true;
509506}
@@ -516,11 +513,10 @@ int am_event_flush_queue(struct am_queue *queue) {
516513
517514 struct am_event * * e = NULL ;
518515 while ((e = am_queue_pop_front (queue )) != NULL ) {
519- const struct am_event * event = * e ;
520516 me -> crit_exit ();
521517 ++ cnt ;
522- AM_ASSERT (event );
523- am_event_free (& event );
518+ AM_ASSERT (* e );
519+ am_event_free (* e );
524520 me -> crit_enter ();
525521 }
526522
0 commit comments