Define certain 'const char *...' arrays as static.
authorBill Meier <wmeier@newsguy.com>
Mon, 1 Jul 2013 15:41:05 +0000 (15:41 -0000)
committerBill Meier <wmeier@newsguy.com>
Mon, 1 Jul 2013 15:41:05 +0000 (15:41 -0000)
 (That is: Don't create the array on the stack each time
  the function is called).

 Reduces code memory usage and execution time.
 (See SVN #50271)

svn path=/trunk/; revision=50300

epan/dissectors/packet-cimd.c
epan/dissectors/packet-enttec.c
epan/strutil.c
wsutil/str_util.c

index 49df5bb1dd5f311b5668e7310757a7ed6b84052e..12ef57dfb249bd815e7aa9fdc3c41644b7008499 100644 (file)
@@ -381,7 +381,7 @@ static void dissect_cimd_ud(tvbuff_t *tvb, proto_tree *tree, gint pindex, gint s
   gint   g_offset, g_size;
   gchar  token[4];
   gchar  ch;
-  const char* mapping[128]  = {
+  static const char* mapping[128]  = {
     "_Oa" , "_L-", ""    , "_Y-", "_e`", "_e'", "_u`", "_i`", "_o`", "_C,",        /*10*/
     ""    , "_O/", "_o/" , ""   , "_A*", "_a*", "_gd", "_--", "_gf", "_gg", "_gl", /*21*/
     "_go" , "_gp", "_gi" , "_gs", "_gt", "_gx", "_XX", "_AE", "_ae", "_ss", "_E'", /*32*/
index 048b0e119545058f81e91a6d5418b8301fcbab6e..83817caaa22ad4213c12659982412c7585184c56 100644 (file)
@@ -181,12 +181,12 @@ dissect_enttec_ack(tvbuff_t *tvb _U_, guint offset, proto_tree *tree _U_)
 static gint
 dissect_enttec_dmx_data(tvbuff_t *tvb, guint offset, proto_tree *tree)
 {
-       const char* chan_format[] = {
+       static const char* chan_format[] = {
                "%2u ",
                "%02x ",
                "%3u "
        };
-       const char* string_format[] = {
+       static const char* string_format[] = {
                "%03x: %s",
                "%3u: %s"
        };
index d7ad0389761c4fbc9660722aef7f7e9e54496e26..6c77002b5d181357e0a26157e0b194edb15ff6ee 100644 (file)
@@ -534,7 +534,7 @@ format_uri(const GByteArray *bytes, const gchar *reserved_chars)
     static gchar *fmtbuf[3];
     static guint fmtbuf_len[3];
     static guint idx;
-    const guchar *reserved_def = ":/?#[]@!$&'()*+,;= ";
+    static const guchar *reserved_def = ":/?#[]@!$&'()*+,;= ";
     const guchar *reserved = reserved_def;
     guint8 c;
     guint column, i;
index c75442353630302140f4b20d6cfcde331b0e180c..9c0aa6e8021e76bce1ac662efce9deec33867d41 100644 (file)
@@ -104,7 +104,7 @@ gchar *format_size(gint64 size, format_size_flags_e flags) {
        int power = 1000;
        int pfx_off = 0;
        gboolean is_small = FALSE;
-       const gchar *prefix[] = {"T", "G", "M", "k", "Ti", "Gi", "Mi", "Ki"};
+       static const gchar *prefix[] = {"T", "G", "M", "k", "Ti", "Gi", "Mi", "Ki"};
        gchar *ret_val;
 
        if ((flags & FORMAT_SIZE_PFX_MASK) == format_size_prefix_iec) {