From 0b744edfa4707fbf824317d0cfb0265c1a3afeec Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 26 Dec 2011 22:18:16 -0800 Subject: [PATCH] Migrate events to std::vector --- event.cpp | 51 ++++++++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/event.cpp b/event.cpp index a3dffa15d..303c9cb30 100644 --- a/event.cpp +++ b/event.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "fallback.h" #include "util.h" @@ -67,7 +68,7 @@ static int active_list=0; /** List of event handlers */ -static array_list_t *events; +static std::vector events; /** List of event handlers that should be removed */ @@ -278,21 +279,18 @@ void event_add_handler( event_t *event ) e = event_copy( event, 0 ); - if( !events ) - events = al_new(); - if( e->type == EVENT_SIGNAL ) { signal_handle( e->param1.signal, 1 ); } - al_push( events, e ); + events.push_back(e); } void event_remove( event_t *criterion ) { - int i; - array_list_t *new_list=0; + size_t i; + std::vector new_list; event_t e; CHECK( criterion, ); @@ -306,12 +304,12 @@ void event_remove( event_t *criterion ) events-list. */ - if( !events ) + if( events.empty() ) return; - for( i=0; i