[asterisk-commits] file: trunk r81348 - /trunk/main/event.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 29 11:25:30 CDT 2007


Author: file
Date: Wed Aug 29 11:25:30 2007
New Revision: 81348

URL: http://svn.digium.com/view/asterisk?view=rev&rev=81348
Log:
Return ast_event_get_ie_raw to using an iterator and fix logic in ast_event_iterator_next.

Modified:
    trunk/main/event.c

Modified: trunk/main/event.c
URL: http://svn.digium.com/view/asterisk/trunk/main/event.c?view=diff&rev=81348&r1=81347&r2=81348
==============================================================================
--- trunk/main/event.c (original)
+++ trunk/main/event.c Wed Aug 29 11:25:30 2007
@@ -372,7 +372,7 @@
 int ast_event_iterator_next(struct ast_event_iterator *iterator)
 {
 	iterator->ie = ((void *) iterator->ie) + sizeof(*iterator->ie) + ntohs(iterator->ie->ie_payload_len);
-	return ((iterator->event_len > (((void *) iterator->ie) - ((void *) iterator->event))) ? -1 : 0);
+	return ((iterator->event_len < (((void *) iterator->ie) - ((void *) iterator->event))) ? -1 : 0);
 }
 
 enum ast_event_ie_type ast_event_iterator_get_ie_type(struct ast_event_iterator *iterator)
@@ -416,20 +416,16 @@
 
 const void *ast_event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type)
 {
-	struct ast_event_ie *ie;
-	uint16_t event_len;
-	
+	struct ast_event_iterator iterator;
+	int res = 0;
+
 	ie_type = ntohs(ie_type);
-	event_len = ntohs(event->event_len);
-	
-	ie = ((void *) event) + sizeof(*event);
-	
-	while ((((void *) ie) - ((void *) event)) < event_len) {
-		if (ie->ie_type == ie_type)
-			return ie->ie_payload;
-		ie = ((void *) ie) + sizeof(*ie) + ntohs(ie->ie_payload_len);
-	}
-	
+
+	for (ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
+		if (ast_event_iterator_get_ie_type(&iterator) == ie_type)
+			return ast_event_iterator_get_ie_raw(&iterator);
+	}
+
 	return NULL;
 }
 




More information about the asterisk-commits mailing list