diff options
Diffstat (limited to 'src/lib/mhd_compat.c')
-rw-r--r-- | src/lib/mhd_compat.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/lib/mhd_compat.c b/src/lib/mhd_compat.c index 3abdc367..6f6c6f9c 100644 --- a/src/lib/mhd_compat.c +++ b/src/lib/mhd_compat.c | |||
@@ -25,7 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "mhd_compat.h" | 27 | #include "mhd_compat.h" |
28 | #if defined(_WIN32) && !defined(__CYGWIN__) | 28 | #if defined(_WIN32) && ! defined(__CYGWIN__) |
29 | #include <stdint.h> | 29 | #include <stdint.h> |
30 | #include <time.h> | 30 | #include <time.h> |
31 | #ifndef HAVE_SNPRINTF | 31 | #ifndef HAVE_SNPRINTF |
@@ -38,7 +38,7 @@ | |||
38 | #include <string.h> /* for memset() */ | 38 | #include <string.h> /* for memset() */ |
39 | #endif /* ! HAVE_CALLOC */ | 39 | #endif /* ! HAVE_CALLOC */ |
40 | 40 | ||
41 | #if defined(_WIN32) && !defined(__CYGWIN__) | 41 | #if defined(_WIN32) && ! defined(__CYGWIN__) |
42 | 42 | ||
43 | #ifndef HAVE_SNPRINTF | 43 | #ifndef HAVE_SNPRINTF |
44 | /* Emulate snprintf function on W32 */ | 44 | /* Emulate snprintf function on W32 */ |
@@ -61,16 +61,16 @@ W32_snprintf (char *__restrict s, | |||
61 | format, | 61 | format, |
62 | args); | 62 | args); |
63 | va_end (args); | 63 | va_end (args); |
64 | if ((int)n == ret) | 64 | if ((int) n == ret) |
65 | s[n - 1] = 0; | 65 | s[n - 1] = 0; |
66 | if (ret >= 0) | 66 | if (ret >= 0) |
67 | return ret; | 67 | return ret; |
68 | } | 68 | } |
69 | va_start(args, | 69 | va_start (args, |
70 | format); | 70 | format); |
71 | ret = _vscprintf (format, | 71 | ret = _vscprintf (format, |
72 | args); | 72 | args); |
73 | va_end(args); | 73 | va_end (args); |
74 | if ( (0 <= ret) && | 74 | if ( (0 <= ret) && |
75 | (0 != n) && | 75 | (0 != n) && |
76 | (NULL == s) ) | 76 | (NULL == s) ) |
@@ -85,30 +85,30 @@ W32_snprintf (char *__restrict s, | |||
85 | #ifndef HAVE_CALLOC | 85 | #ifndef HAVE_CALLOC |
86 | 86 | ||
87 | #ifdef __has_builtin | 87 | #ifdef __has_builtin |
88 | # if __has_builtin(__builtin_mul_overflow) | 88 | # if __has_builtin (__builtin_mul_overflow) |
89 | # define MHD_HAVE_NUL_OVERFLOW 1 | 89 | # define MHD_HAVE_NUL_OVERFLOW 1 |
90 | # endif | 90 | # endif |
91 | #elif __GNUC__+0 >= 5 | 91 | #elif __GNUC__ + 0 >= 5 |
92 | # define MHD_HAVE_NUL_OVERFLOW 1 | 92 | # define MHD_HAVE_NUL_OVERFLOW 1 |
93 | #endif /* __GNUC__ >= 5 */ | 93 | #endif /* __GNUC__ >= 5 */ |
94 | 94 | ||
95 | 95 | ||
96 | void *MHD_calloc_(size_t nelem, size_t elsize) | 96 | void *MHD_calloc_ (size_t nelem, size_t elsize) |
97 | { | 97 | { |
98 | size_t alloc_size; | 98 | size_t alloc_size; |
99 | void *ptr; | 99 | void *ptr; |
100 | #ifdef MHD_HAVE_NUL_OVERFLOW | 100 | #ifdef MHD_HAVE_NUL_OVERFLOW |
101 | if (__builtin_mul_overflow(nelem, elsize, &alloc_size) || 0 == alloc_size) | 101 | if (__builtin_mul_overflow (nelem, elsize, &alloc_size) ||(0 == alloc_size)) |
102 | return NULL; | 102 | return NULL; |
103 | #else /* ! MHD_HAVE_NUL_OVERFLOW */ | 103 | #else /* ! MHD_HAVE_NUL_OVERFLOW */ |
104 | alloc_size = nelem * elsize; | 104 | alloc_size = nelem * elsize; |
105 | if (0 == alloc_size || elsize != alloc_size / nelem) | 105 | if ((0 == alloc_size)||(elsize != alloc_size / nelem)) |
106 | return NULL; | 106 | return NULL; |
107 | #endif /* ! MHD_HAVE_NUL_OVERFLOW */ | 107 | #endif /* ! MHD_HAVE_NUL_OVERFLOW */ |
108 | ptr = malloc (alloc_size); | 108 | ptr = malloc (alloc_size); |
109 | if (NULL == ptr) | 109 | if (NULL == ptr) |
110 | return NULL; | 110 | return NULL; |
111 | memset(ptr, 0, alloc_size); | 111 | memset (ptr, 0, alloc_size); |
112 | return ptr; | 112 | return ptr; |
113 | } | 113 | } |
114 | #endif /* ! HAVE_CALLOC */ | 114 | #endif /* ! HAVE_CALLOC */ |