aboutsummaryrefslogtreecommitdiffstats
path: root/epan/diam_dict.l
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-04-11 11:31:17 -0700
committerMichael Mann <mmann78@netscape.net>2016-04-13 02:16:20 +0000
commitcf6501eb45408c83467160c8ed026c6aab347642 (patch)
tree84755bcc3bbdb9a1b7dcc69e171ab2f947f0ed0a /epan/diam_dict.l
parentf6b8b4dca5c05f0e6011ca8d8ef670beb911ac39 (diff)
Windows: Remove the need for _CRT_NONSTDC_NO_DEPRECATE.
Replace some function calls with their non-deprecated equivalents so that we can remove _CRT_NONSTDC_NO_DEPRECATE from CMakeLists.txt and config.nmake. Leave _CRT_SECURE_NO_DEPRECATE in place. Removing it failed with 145 warnings and 72 errors. Note that we could probably improve startup performance by using wmem in diam_dict.*. Change-Id: I6e130003de838aebedbdd1aa78c50de8a339ddcb Reviewed-on: https://code.wireshark.org/review/14883 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/diam_dict.l')
-rw-r--r--epan/diam_dict.l22
1 files changed, 16 insertions, 6 deletions
diff --git a/epan/diam_dict.l b/epan/diam_dict.l
index 47aa11eb50..a82d81c5f2 100644
--- a/epan/diam_dict.l
+++ b/epan/diam_dict.l
@@ -94,6 +94,16 @@
#include <epan/to_str.h>
#include <wsutil/file_util.h>
+/*
+ * Deprecated CRT functions. We call malloc+free quite a bit here. We could
+ * probably improve startup performance by using wmem instead.
+ */
+#ifdef _WIN32
+#define ws_strdup _strdup
+#else
+#define ws_strdup strdup
+#endif
+
typedef struct entity_t {
char* name;
char* file;
@@ -284,10 +294,10 @@ description_attr description=\042
}
<XMLPI_ATTRS>{xmlpi_key_attr} BEGIN XMLPI_GETKEY;
-<XMLPI_GETKEY>{ndquot} { yyextra->xmlpi->key = strdup(yytext); BEGIN XMLPI_ATTRS; }
+<XMLPI_GETKEY>{ndquot} { yyextra->xmlpi->key = ws_strdup(yytext); BEGIN XMLPI_ATTRS; }
<XMLPI_ATTRS>{xmlpi_value_attr} BEGIN XMLPI_GETVAL;
-<XMLPI_GETVAL>{ndquot} { yyextra->xmlpi->value = strdup(yytext); BEGIN XMLPI_ATTRS; }
+<XMLPI_GETVAL>{ndquot} { yyextra->xmlpi->value = ws_strdup(yytext); BEGIN XMLPI_ATTRS; }
<XMLPI_ATTRS>.
<XMLPI_ATTRS>{xmlpi_end} BEGIN LOADING;
@@ -296,14 +306,14 @@ description_attr description=\042
<LOADING>{start_entity} BEGIN ENTITY;
<ENTITY>{entityname} {
entity_t* e = g_new(entity_t,1);
- e->name = strdup(yytext);
+ e->name = ws_strdup(yytext);
e->next = yyextra->ents;
yyextra->ents = e;
BEGIN GET_SYSTEM;
};
<GET_SYSTEM>{system} BEGIN GET_FILE;
<GET_FILE>{ndquot} {
- yyextra->ents->file = strdup(yytext);
+ yyextra->ents->file = ws_strdup(yytext);
BEGIN END_ENTITY;
}
<END_ENTITY>{end_entity} BEGIN LOADING;
@@ -384,7 +394,7 @@ description_attr description=\042
<GET_ATTR>{ndquot} {
- *(yyextra->attr_str) = strdup(yytext);
+ *(yyextra->attr_str) = ws_strdup(yytext);
D(("%s\n",yytext));
yyextra->attr_str = NULL;
BEGIN END_ATTR;
@@ -540,7 +550,7 @@ description_attr description=\042
<AVP_ATTRS>{stop_end} { BEGIN IN_APPL; }
-<IN_AVP>{grouped_start} { yyextra->avp->type = strdup("Grouped"); };
+<IN_AVP>{grouped_start} { yyextra->avp->type = ws_strdup("Grouped"); };
<IN_AVP>{grouped_end} ;
<IN_AVP>{type_start} { BEGIN TYPE_ATTRS; }