version 1.4, 2010/02/10 10:14:18
|
version 1.30, 2011/09/26 15:57:09
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.11 |
RPL/2 (R) version 4.1.4 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2011 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 21
|
Line 21
|
|
|
|
|
#include "rpl.h" |
#include "rpl.h" |
#include <stdarg.h> |
|
|
|
|
|
int |
int |
Line 29 valsprintf(unsigned char **strp, const c
|
Line 28 valsprintf(unsigned char **strp, const c
|
{ |
{ |
size_t bs; |
size_t bs; |
size_t s; |
size_t s; |
|
|
unsigned char *b = NULL; |
unsigned char *b = NULL; |
|
|
|
va_list cap; |
|
|
for(bs = 1024;; bs *= 2) |
for(bs = 1024;; bs *= 2) |
{ |
{ |
|
va_copy(cap, ap); |
|
|
if (b != NULL) |
if (b != NULL) |
{ |
{ |
free(b); |
free(b); |
} |
} |
|
|
if ((b = malloc(sizeof(*b) * bs)) == NULL) |
if ((b = malloc(sizeof(*b) * bs)) == NULL) |
{ |
{ |
return -1; |
return -1; |
} |
} |
|
|
if (((int) (s = vsnprintf(b, bs, fmt, ap))) < 0) |
if (((int) (s = vsnprintf(b, bs, fmt, cap))) < 0) |
{ |
{ |
free(b); |
free(b); |
return -1; |
return -1; |
} |
} |
|
|
if (s < bs) |
if (s < bs) |
{ |
{ |
break; |
break; |
} |
} |