X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e7cdc14647fc01e576c8e820bf51cc96a679be17..b0943ccb32bf2fbe0bb7f2d4fb41798cc8d0af6b:/src/xbt/snprintf.c diff --git a/src/xbt/snprintf.c b/src/xbt/snprintf.c index 83c8181cc6..12672131d1 100644 --- a/src/xbt/snprintf.c +++ b/src/xbt/snprintf.c @@ -1,3 +1,8 @@ +/* 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 @@ -316,7 +321,7 @@ #define LINUX_COMPATIBLE #endif -#include "portable.h" /* to get a working stdarg.h */ +#include "src/portable.h" /* to get a working stdarg.h */ #include #include @@ -365,17 +370,17 @@ #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 */ @@ -422,18 +427,20 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, #endif #endif + /* FIXME: better place */ +#include "xbt/sysdep.h" + /* declarations */ -static char credits[] = "\n\ - @(#)snprintf.c, v2.2: Mark Martinec, \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"; +/* MPOQUET FIXME: the __foo__ function generates a warning on clang 3.7.0 + MPOQUET FIXME: the credits is unused if __foo__ is commented*/ -static void __foo__(void) -{ - printf("%s", credits); - __foo__(); -} +/* + Old copyright + snprintf.c, v2.2: Mark Martinec, + 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 */ ...) @@ -447,7 +454,7 @@ 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; @@ -476,7 +483,7 @@ int vasprintf(char **ptr, const char *fmt, va_list ap) 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; @@ -504,7 +511,7 @@ int asnprintf(char **ptr, size_t str_m, const char *fmt, /*args */ ...) /* 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; @@ -538,7 +545,7 @@ int vasnprintf(char **ptr, size_t str_m, const char *fmt, va_list ap) /* 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; @@ -1165,9 +1172,6 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, #endif - /* FIXME: better place */ -#include "xbt/sysdep.h" - char *bvprintf(const char *fmt, va_list ap) { char *res;