diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-07-15 13:59:23 -0700 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2016-07-21 20:09:03 +0000 |
commit | 913e0f408c48f3baf6933807f9cfe4195fde5c75 (patch) | |
tree | 285e4dd8b2e5c660bc04b0256323de6622082a10 /epan/column-utils.c | |
parent | 97d194cd3cb7fa3806a7bb83f83f06ee2eda418b (diff) |
Use Windows CRT string functions in some places.
Copy wsutil/wsprintf.h from change 16537. Update it to use functions
appropriate to Visual C++ >= 2015, < 2015, and everything else. Add
notes about specific API issues.
Update epan/expert.c to use ws_snprintf, since the VS profiler shows it
as a minor hot spot. This reduces load time for a large-ish capture from
~14s to ~12s here.
Migrate a previous column-utils change.
Change-Id: Id4064b7c06c35fd447b63c73f731afee181df4f9
Reviewed-on: https://code.wireshark.org/review/16483
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: João Valverde <j@v6e.pt>
Diffstat (limited to 'epan/column-utils.c')
-rw-r--r-- | epan/column-utils.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/epan/column-utils.c b/epan/column-utils.c index a3bfe87ecc..a4a9cf9a24 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -25,10 +25,6 @@ #include <string.h> #include <time.h> -#ifdef _WIN32 -#include <strsafe.h> -#endif - #include "column-utils.h" #include "timestamp.h" #include "to_str.h" @@ -45,7 +41,9 @@ #include <epan/strutil.h> #include <epan/epan.h> #include <epan/dfilter/dfilter.h> + #include <wsutil/utf8_entities.h> +#include <wsutil/ws_printf.h> #ifdef HAVE_LUA #include <epan/wslua/wslua.h> @@ -445,21 +443,9 @@ col_snprint_port(gchar *buf, gulong buf_siz, port_type typ, guint16 val) if (gbl_resolv_flags.transport_name && (str = try_serv_name_lookup(typ, val)) != NULL) { -/* - * I'm not sure what GLib is doing on Windows, but according to the VS 2013 - * profiler StringCchPrintf does it in 100x fewer samples. - */ -#ifdef _WIN32 - StringCchPrintfA(buf, buf_siz, "%s(%hu)", str, val); -#else - g_snprintf(buf, buf_siz, "%s(%"G_GUINT16_FORMAT")", str, val); -#endif + ws_snprintf(buf, buf_siz, "%s(%"G_GUINT16_FORMAT")", str, val); } else { -#ifdef _WIN32 - StringCchPrintfA(buf, buf_siz, "%hu", val); -#else - g_snprintf(buf, buf_siz, "%"G_GUINT16_FORMAT, val); -#endif + ws_snprintf(buf, buf_siz, "%"G_GUINT16_FORMAT, val); } } |