aboutsummaryrefslogtreecommitdiff
path: root/src/util/common_allocation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-04 14:00:32 +0000
commit83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch)
treed0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/util/common_allocation.c
parent28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff)
downloadgnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz
gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip
curly wars / auto-indentation
Diffstat (limited to 'src/util/common_allocation.c')
-rw-r--r--src/util/common_allocation.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c
index 31da5829b..340ad5334 100644
--- a/src/util/common_allocation.c
+++ b/src/util/common_allocation.c
@@ -65,10 +65,10 @@ GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber)
65 GNUNET_assert_at (size <= GNUNET_MAX_MALLOC_CHECKED, filename, linenumber); 65 GNUNET_assert_at (size <= GNUNET_MAX_MALLOC_CHECKED, filename, linenumber);
66 ret = GNUNET_xmalloc_unchecked_ (size, filename, linenumber); 66 ret = GNUNET_xmalloc_unchecked_ (size, filename, linenumber);
67 if (ret == NULL) 67 if (ret == NULL)
68 { 68 {
69 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc"); 69 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc");
70 abort (); 70 abort ();
71 } 71 }
72 return ret; 72 return ret;
73} 73}
74 74
@@ -86,7 +86,7 @@ GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber)
86 */ 86 */
87void * 87void *
88GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename, 88GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename,
89 int linenumber) 89 int linenumber)
90{ 90{
91 void *ret; 91 void *ret;
92 92
@@ -101,10 +101,10 @@ GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename,
101 GNUNET_assert_at (size < INT_MAX, filename, linenumber); 101 GNUNET_assert_at (size < INT_MAX, filename, linenumber);
102 ret = malloc (size); 102 ret = malloc (size);
103 if (ret == NULL) 103 if (ret == NULL)
104 { 104 {
105 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc"); 105 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc");
106 abort (); 106 abort ();
107 } 107 }
108#ifdef W32_MEM_LIMIT 108#ifdef W32_MEM_LIMIT
109 *((size_t *) ret) = size; 109 *((size_t *) ret) = size;
110 ret = &((size_t *) ret)[1]; 110 ret = &((size_t *) ret)[1];
@@ -172,10 +172,10 @@ GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber)
172#endif 172#endif
173 ptr = realloc (ptr, n); 173 ptr = realloc (ptr, n);
174 if ((NULL == ptr) && (n > 0)) 174 if ((NULL == ptr) && (n > 0))
175 { 175 {
176 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "realloc"); 176 LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "realloc");
177 abort (); 177 abort ();
178 } 178 }
179#ifdef W32_MEM_LIMIT 179#ifdef W32_MEM_LIMIT
180 ptr = &((size_t *) ptr)[1]; 180 ptr = &((size_t *) ptr)[1];
181#endif 181#endif
@@ -233,7 +233,7 @@ GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber)
233 */ 233 */
234char * 234char *
235GNUNET_xstrndup_ (const char *str, size_t len, const char *filename, 235GNUNET_xstrndup_ (const char *str, size_t len, const char *filename,
236 int linenumber) 236 int linenumber)
237{ 237{
238 char *res; 238 char *res;
239 239
@@ -260,7 +260,7 @@ GNUNET_xstrndup_ (const char *str, size_t len, const char *filename,
260 */ 260 */
261void 261void
262GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount, 262GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount,
263 unsigned int newCount, const char *filename, int linenumber) 263 unsigned int newCount, const char *filename, int linenumber)
264{ 264{
265 void *tmp; 265 void *tmp;
266 size_t size; 266 size_t size;
@@ -268,22 +268,22 @@ GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount,
268 GNUNET_assert_at (INT_MAX / elementSize > newCount, filename, linenumber); 268 GNUNET_assert_at (INT_MAX / elementSize > newCount, filename, linenumber);
269 size = newCount * elementSize; 269 size = newCount * elementSize;
270 if (size == 0) 270 if (size == 0)
271 { 271 {
272 tmp = NULL; 272 tmp = NULL;
273 } 273 }
274 else 274 else
275 { 275 {
276 tmp = GNUNET_xmalloc_ (size, filename, linenumber); 276 tmp = GNUNET_xmalloc_ (size, filename, linenumber);
277 memset (tmp, 0, size); /* client code should not rely on this, though... */ 277 memset (tmp, 0, size); /* client code should not rely on this, though... */
278 if (*oldCount > newCount) 278 if (*oldCount > newCount)
279 *oldCount = newCount; /* shrink is also allowed! */ 279 *oldCount = newCount; /* shrink is also allowed! */
280 memcpy (tmp, *old, elementSize * (*oldCount)); 280 memcpy (tmp, *old, elementSize * (*oldCount));
281 } 281 }
282 282
283 if (*old != NULL) 283 if (*old != NULL)
284 { 284 {
285 GNUNET_xfree_ (*old, filename, linenumber); 285 GNUNET_xfree_ (*old, filename, linenumber);
286 } 286 }
287 *old = tmp; 287 *old = tmp;
288 *oldCount = newCount; 288 *oldCount = newCount;
289} 289}