A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use more readable alternatives for string::compare().
[simgrid.git]
/
src
/
xbt
/
snprintf.c
diff --git
a/src/xbt/snprintf.c
b/src/xbt/snprintf.c
index
79223df
..
e3222d3
100644
(file)
--- a/
src/xbt/snprintf.c
+++ b/
src/xbt/snprintf.c
@@
-1,4
+1,4
@@
-/* Copyright (c) 2005-202
0
. The SimGrid Team.
+/* Copyright (c) 2005-202
3
. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
@@
-55,14
+55,14
@@
#endif
#include <stdio.h>
#endif
#include <stdio.h>
-#include "xbt/sysdep.h" /* xbt_abort() */
#include "src/internal_config.h" /* Do we need vasprintf? */
#include "src/internal_config.h" /* Do we need vasprintf? */
-
-#include
<assert.h>
+#include "xbt/asserts.h" /* xbt_abort() */
+#include
"xbt/misc.h"
#if !HAVE_VASPRINTF
#if !HAVE_VASPRINTF
+#include <assert.h>
#include <stdarg.h> /* vsnprintf */
#include <stdarg.h> /* vsnprintf */
-int vasprintf(char
**ptr, const char *fmt, va_list ap
);
+int vasprintf(char
** ptr, const char* fmt, va_list ap) XBT_ATTRIB_PRINTF(2, 0
);
int vasprintf(char **ptr, const char *fmt, va_list ap)
{
size_t str_m;
int vasprintf(char **ptr, const char *fmt, va_list ap)
{
size_t str_m;
@@
-75,8
+75,9
@@
int vasprintf(char **ptr, const char *fmt, va_list ap)
str_l = vsnprintf(NULL, (size_t) 0, fmt, ap2); /*get required size */
va_end(ap2);
}
str_l = vsnprintf(NULL, (size_t) 0, fmt, ap2); /*get required size */
va_end(ap2);
}
- xbt_assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
- *ptr = (char *) xbt_malloc(str_m = (size_t) str_l + 1);
+ assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
+ *ptr = (char*)malloc(str_m = (size_t)str_l + 1);
+ assert(*ptr != NULL);
int str_l2 = vsnprintf(*ptr, str_m, fmt, ap);
assert(str_l2 == str_l);
int str_l2 = vsnprintf(*ptr, str_m, fmt, ap);
assert(str_l2 == str_l);