diff options
author | Jaap Keuter <jaap.keuter@xs4all.nl> | 2007-10-11 19:40:58 +0000 |
---|---|---|
committer | Jaap Keuter <jaap.keuter@xs4all.nl> | 2007-10-11 19:40:58 +0000 |
commit | c1484a08dfaa778cc070cad795fbc76b60d3417b (patch) | |
tree | 37659dd759c974b9f651d286ec8c96c7ba8404e9 /epan/value_string.c | |
parent | d0e34ab8c359963a1e428d2ea8bd1ea69a20d620 (diff) |
Allow for dynamic value string array selection.
svn path=/trunk/; revision=23149
Diffstat (limited to 'epan/value_string.c')
-rw-r--r-- | epan/value_string.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/epan/value_string.c b/epan/value_string.c index 49d44d5b29..a6c39ee7d7 100644 --- a/epan/value_string.c +++ b/epan/value_string.c @@ -56,16 +56,18 @@ const gchar* match_strval_idx(guint32 val, const value_string *vs, gint *idx) { gint i = 0; - while (vs[i].strptr) { - if (vs[i].value == val) { - *idx = i; - return(vs[i].strptr); + if(vs) { + while (vs[i].strptr) { + if (vs[i].value == val) { + *idx = i; + return(vs[i].strptr); + } + i++; } - i++; } *idx = -1; - return(NULL); + return NULL; } /* Like match_strval_idx(), but doesn't return the index. */ @@ -137,16 +139,18 @@ const gchar *match_strrval_idx(guint32 val, const range_string *rs, gint *idx) { gint i = 0; - while(rs[i].strptr) { - if( (val >= rs[i].value_min) && (val <= rs[i].value_max) ) { - *idx = i; - return (rs[i].strptr); + if(rs) { + while(rs[i].strptr) { + if( (val >= rs[i].value_min) && (val <= rs[i].value_max) ) { + *idx = i; + return (rs[i].strptr); + } + i++; } - i++; } *idx = -1; - return (NULL); + return NULL; } /* Like match_strrval_idx(), but doesn't return the index. */ |