Changes in uspace/lib/c/generic/io/asprintf.c [a9763c6:ce52ae70] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/io/asprintf.c
ra9763c6 rce52ae70 76 76 * the newly allocated string. 77 77 * @fmt Format string. 78 * @args Variable argument list79 *80 * @return Number of characters printed or a negative error code.81 *82 */83 int vasprintf(char **strp, const char *fmt, va_list args)84 {85 va_list args2;86 va_copy(args2, args);87 int ret = vprintf_size(fmt, args2);88 va_end(args2);89 90 if (ret > 0) {91 *strp = malloc(STR_BOUNDS(ret) + 1);92 if (*strp == NULL)93 return -1;94 95 vsnprintf(*strp, STR_BOUNDS(ret) + 1, fmt, args);96 }97 98 return ret;99 }100 101 /** Allocate and print to string.102 *103 * @param strp Address of the pointer where to store the address of104 * the newly allocated string.105 * @fmt Format string.106 78 * 107 79 * @return Number of characters printed or a negative error code. … … 112 84 va_list args; 113 85 va_start(args, fmt); 114 int ret = v asprintf(strp,fmt, args);86 int ret = vprintf_size(fmt, args); 115 87 va_end(args); 88 89 if (ret > 0) { 90 *strp = malloc(STR_BOUNDS(ret) + 1); 91 if (*strp == NULL) 92 return -1; 93 94 va_start(args, fmt); 95 vsnprintf(*strp, STR_BOUNDS(ret) + 1, fmt, args); 96 va_end(args); 97 } 116 98 117 99 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.