~ubuntu-branches/ubuntu/precise/libpgm/precise

« back to all changes in this revision

Viewing changes to openpgm/pgm/mem.c.c89.patch

  • Committer: Bazaar Package Importer
  • Author(s): Gabriel de Perthuis
  • Date: 2011-04-07 16:48:52 UTC
  • Revision ID: james.westby@ubuntu.com-20110407164852-8uamem42ojeptj6l
Tags: upstream-5.1.116~dfsg
ImportĀ upstreamĀ versionĀ 5.1.116~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- mem.c       2011-03-29 20:36:18.000000000 +0800
 
2
+++ mem.c89.c   2011-03-29 20:36:24.000000000 +0800
 
3
@@ -79,16 +79,24 @@
 
4
        if (NULL == string)
 
5
                return result;
 
6
 
 
7
+/* C++ warning completely irrelevant for C */
 
8
+#pragma warning( disable : 4996 )
 
9
        if (!strcasecmp (string, "all"))
 
10
        {
 
11
-               for (unsigned i = 0; i < nkeys; i++)
 
12
+               {
 
13
+               unsigned i;
 
14
+               for (i = 0; i < nkeys; i++)
 
15
                        result |= keys[i].value;
 
16
+               }
 
17
        }
 
18
        else if (!strcasecmp (string, "help"))
 
19
        {
 
20
                fprintf (stderr, "Supported debug values:");
 
21
-               for (unsigned i = 0; i < nkeys; i++)
 
22
+               {
 
23
+               unsigned i;
 
24
+               for (i = 0; i < nkeys; i++)
 
25
                        fprintf (stderr, " %s", keys[i].key);
 
26
+               }
 
27
                fprintf (stderr, "\n");
 
28
        }
 
29
        else
 
30
@@ -97,14 +105,18 @@
 
31
                        const char* q = strpbrk (string, ":;, \t");
 
32
                        if (!q)
 
33
                                q = string + strlen (string);
 
34
-                       for (unsigned i = 0; i < nkeys; i++)
 
35
+                       {
 
36
+                       unsigned i;
 
37
+                       for (i = 0; i < nkeys; i++)
 
38
                                if (debug_key_matches (keys[i].key, string, (unsigned)(q - string)))
 
39
                                        result |= keys[i].value;
 
40
+                       }
 
41
                        string = q;
 
42
                        if (*string)
 
43
                                string++;
 
44
                }
 
45
        }
 
46
+#pragma warning( default : 4996 )
 
47
        return result;
 
48
 }
 
49
 
 
50
@@ -122,11 +134,13 @@
 
51
        if (pgm_atomic_exchange_and_add32 (&mem_ref_count, 1) > 0)
 
52
                return;
 
53
 
 
54
+       {
 
55
        const errno_t err = pgm_dupenv_s (&env, &envlen, "PGM_DEBUG");
 
56
        if (0 == err && envlen > 0) {
 
57
                flags = pgm_parse_debug_string (env, keys, PGM_N_ELEMENTS (keys));
 
58
                pgm_free (env);
 
59
        }
 
60
+       }
 
61
 
 
62
        if (flags & 1)
 
63
                pgm_mem_gc_friendly = TRUE;
 
64
@@ -159,11 +173,11 @@
 
65
 #ifdef __GNUC__
 
66
                pgm_fatal ("file %s: line %d (%s): failed to allocate %" PRIzu " bytes",
 
67
                        __FILE__, __LINE__, __PRETTY_FUNCTION__,
 
68
-                       n_bytes);
 
69
+                       (unsigned long)n_bytes);
 
70
 #else
 
71
                pgm_fatal ("file %s: line %d: failed to allocate %" PRIzu " bytes",
 
72
                        __FILE__, __LINE__,
 
73
-                       n_bytes);
 
74
+                       (unsigned long)n_bytes);
 
75
 #endif
 
76
                abort ();
 
77
        }
 
78
@@ -182,11 +196,11 @@
 
79
 #ifdef __GNUC__
 
80
                pgm_fatal ("file %s: line %d (%s): overflow allocating %" PRIzu "*%" PRIzu " bytes",
 
81
                        __FILE__, __LINE__, __PRETTY_FUNCTION__,
 
82
-                       n_blocks, block_bytes);
 
83
+                       (unsigned long)n_blocks, (unsigned long)block_bytes);
 
84
 #else
 
85
                pgm_fatal ("file %s: line %d: overflow allocating %" PRIzu "*%" PRIzu " bytes",
 
86
                        __FILE__, __LINE__,
 
87
-                       n_blocks, block_bytes);
 
88
+                       (unsigned long)n_blocks, (unsigned long)block_bytes);
 
89
 #endif
 
90
        }
 
91
        return pgm_malloc (n_blocks * block_bytes);
 
92
@@ -206,11 +220,11 @@
 
93
 #ifdef __GNUC__
 
94
                pgm_fatal ("file %s: line %d (%s): failed to allocate %" PRIzu " bytes",
 
95
                        __FILE__, __LINE__, __PRETTY_FUNCTION__,
 
96
-                       n_bytes);
 
97
+                       (unsigned long)n_bytes);
 
98
 #else
 
99
                pgm_fatal ("file %s: line %d: failed to allocate %" PRIzu " bytes",
 
100
                        __FILE__, __LINE__,
 
101
-                       n_bytes);
 
102
+                       (unsigned long)n_bytes);
 
103
 #endif
 
104
                abort ();
 
105
        }
 
106
@@ -232,11 +246,11 @@
 
107
 #ifdef __GNUC__
 
108
                pgm_fatal ("file %s: line %d (%s): failed to allocate %" PRIzu "*%" PRIzu " bytes",
 
109
                        __FILE__, __LINE__, __PRETTY_FUNCTION__,
 
110
-                       n_blocks, block_bytes);
 
111
+                       (unsigned long)n_blocks, (unsigned long)block_bytes);
 
112
 #else
 
113
                pgm_fatal ("file %s: line %d: failed to allocate %" PRIzu "*%" PRIzu " bytes",
 
114
                        __FILE__, __LINE__,
 
115
-                       n_blocks, block_bytes);
 
116
+                       (unsigned long)n_blocks, (unsigned long)block_bytes);
 
117
 #endif
 
118
                abort ();
 
119
        }