--- rpl/src/asprintf.c 2010/02/01 14:05:03 1.3 +++ rpl/src/asprintf.c 2018/12/24 15:54:58 1.64 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.10 - Copyright (C) 1989-2010 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.30 + Copyright (C) 1989-2018 Dr. BERTRAND Joël This file is part of RPL/2. @@ -21,35 +21,40 @@ #include "rpl.h" -#include int -valsprintf(unsigned char **strp, const char *fmt, va_list ap) +valsprintf(struct_processus *s_etat_processus, + unsigned char **strp, const char *fmt, va_list ap) { size_t bs; size_t s; + unsigned char *b = NULL; + va_list cap; + for(bs = 1024;; bs *= 2) { + va_copy(cap, ap); + if (b != NULL) { free(b); } - if ((b = malloc(sizeof(*b) * bs)) == NULL) + if ((b = malloc(sizeof(*b) * bs)) == NULL) { return -1; } - if (((int) (s = vsnprintf(b, bs, fmt, ap))) < 0) + if (((int) (s = (size_t) vsnprintf(b, bs, fmt, cap))) < 0) { free(b); return -1; } - if (s < bs) + if (s < bs) { break; } @@ -61,18 +66,19 @@ valsprintf(unsigned char **strp, const c return -1; } - return s; + return((int) s); } int -alsprintf(unsigned char **strp, const char *fmt, ...) +alsprintf(struct_processus *s_etat_processus, + unsigned char **strp, const char *fmt, ...) { int done; va_list arg; va_start(arg, fmt); - done = valsprintf(strp, fmt, arg); + done = valsprintf(s_etat_processus, strp, fmt, arg); va_end(arg); return(done);