diff options
author | Evan Huus <eapache@gmail.com> | 2014-03-02 10:19:41 -0500 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-03-02 21:52:09 +0000 |
commit | 9afdd44eec055a06291f3ccd9d12ebd2fcf4a809 (patch) | |
tree | 5e8cbf1b0f052c0affc8ea76f562fbe999f8659e /epan | |
parent | 0f2014bf21aaff82a2d40e5a1eab080854c48ce9 (diff) |
Improve SCTP association lookup.
It's still O(n) in the worst case since the comparison function doesn't appear
to be suitable for use in a tree or hash-table, but at least we no longer spend
O(n) by default just finding the end of the list so we can iterate backwards.
Discovered while investigating bug #9823, but probably not the cause of that
bug.
Change-Id: Ib6c3691cff8e7fa49703df7c75635ef797c8fbe8
Reviewed-on: https://code.wireshark.org/review/443
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-sctp.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c index 27a4aedb6d..0523fb5f4e 100644 --- a/epan/dissectors/packet-sctp.c +++ b/epan/dissectors/packet-sctp.c @@ -507,7 +507,7 @@ typedef struct _infodata_t { guint16 direction; } infodata_t; -static GList *assoc_info_list = NULL; +static GSList *assoc_info_list = NULL; static guint num_assocs = 0; UAT_CSTRING_CB_DEF(type_fields, type_name, type_field_t) @@ -650,11 +650,11 @@ static infodata_t find_assoc_index(assoc_info_t* tmpinfo) { assoc_info_t *info = NULL; - GList* list; + GSList* list; gboolean cmp = FALSE; infodata_t inf; - if ((list = g_list_last(assoc_info_list))!=NULL) { + if ((list = assoc_info_list) != NULL) { while (list) { cmp = sctp_assoc_vtag_cmp(tmpinfo, (assoc_info_t*)(list->data)); if (cmp < ASSOC_NOT_FOUND) { @@ -676,7 +676,7 @@ find_assoc_index(assoc_info_t* tmpinfo) inf.direction = info->direction; return inf; } - list = g_list_previous(list); + list = g_slist_next(list); } } info = wmem_new0(wmem_file_scope(), assoc_info_t); @@ -687,7 +687,7 @@ find_assoc_index(assoc_info_t* tmpinfo) info->verification_tag2 = tmpinfo->verification_tag2; info->initiate_tag = tmpinfo->initiate_tag; num_assocs++; - assoc_info_list = g_list_append(assoc_info_list, info); + assoc_info_list = g_slist_prepend(assoc_info_list, info); inf.assoc_index = info->assoc_index; inf.direction = 1; return inf; |