+/* Copyright (c) 2005-2010, 2012-2015. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
/*
* snprintf.c - a portable implementation of snprintf
#define LINUX_COMPATIBLE
#endif
-#include "portable.h" /* to get a working stdarg.h */
+#include "src/portable.h" /* to get a working stdarg.h */
#include <sys/types.h>
#include <string.h>
#endif
#define fast_memcpy(d,s,n) \
- { register size_t nn = (size_t)(n); \
+ { size_t nn = (size_t)(n); \
if (nn >= breakeven_point) memcpy((d), (s), nn); \
else if (nn > 0) { /* proc call overhead is worth only for large strings*/\
- register char *dd; register const char *ss; \
+ char *dd; const char *ss; \
for (ss=(s), dd=(d); nn>0; nn--) *dd++ = *ss++; } }
#define fast_memset(d,c,n) \
- { register size_t nn = (size_t)(n); \
+ { size_t nn = (size_t)(n); \
if (nn >= breakeven_point) memset((d), (int)(c), nn); \
else if (nn > 0) { /* proc call overhead is worth only for large strings*/\
- register char *dd; register const int cc=(int)(c); \
+ char *dd; const int cc=(int)(c); \
for (dd=(d); nn>0; nn--) *dd++ = cc; } }
/* prototypes */
#endif
#endif
-/* declarations */
+ /* FIXME: better place */
+#include "xbt/sysdep.h"
-static char credits[] = "\n\
- @(#)snprintf.c, v2.2: Mark Martinec, <mark.martinec@ijs.si>\n\
- @(#)snprintf.c, v2.2: Copyright 1999, Mark Martinec. Frontier Artistic License applies.\n\
- @(#)snprintf.c, v2.2: http://www.ijs.si/software/snprintf/\n";
+/* declarations */
-static void __foo__(void)
-{
- printf("%s", credits);
- __foo__();
-}
+/*
+ Old copyright
+ snprintf.c, v2.2: Mark Martinec, <mark.martinec@ijs.si>
+ snprintf.c, v2.2: Copyright 1999, Mark Martinec. Frontier Artistic License applies.
+ snprintf.c, v2.2: http://www.ijs.si/software/snprintf
+*/
#if defined(NEED_ASPRINTF)
int asprintf(char **ptr, const char *fmt, /*args */ ...)
str_l = portable_vsnprintf(NULL, (size_t) 0, fmt, ap);
va_end(ap);
assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
- *ptr = (char *) malloc(str_m = (size_t) str_l + 1);
+ *ptr = (char *) xbt_malloc(str_m = (size_t) str_l + 1);
if (*ptr == NULL) {
errno = ENOMEM;
str_l = -1;
va_end(ap2);
}
assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
- *ptr = (char *) malloc(str_m = (size_t) str_l + 1);
+ *ptr = (char *) xbt_malloc(str_m = (size_t) str_l + 1);
if (*ptr == NULL) {
errno = ENOMEM;
str_l = -1;
/* if str_m is 0, no buffer is allocated, just set *ptr to NULL */
if (str_m == 0) { /* not interested in resulting string, just return size */
} else {
- *ptr = (char *) malloc(str_m);
+ *ptr = (char *) xbt_malloc(str_m);
if (*ptr == NULL) {
errno = ENOMEM;
str_l = -1;
/* if str_m is 0, no buffer is allocated, just set *ptr to NULL */
if (str_m == 0) { /* not interested in resulting string, just return size */
} else {
- *ptr = (char *) malloc(str_m);
+ *ptr = (char *) xbt_malloc(str_m);
if (*ptr == NULL) {
errno = ENOMEM;
str_l = -1;
#endif
- /* FIXME: better place */
-#include "xbt/sysdep.h"
-
char *bvprintf(const char *fmt, va_list ap)
{
char *res;
/* Do not want to use xbt_die() here, as it uses the logging
* infrastucture and may fail to allocate memory too. */
fprintf(stderr, "bprintf: vasprintf failed. Aborting.\n");
- abort();
+ xbt_abort();
}
return res;
}