Changeset d5a89a3 in mainline for uspace/lib/c/generic/io/asprintf.c


Ignore:
Timestamp:
2019-02-11T22:31:04Z (6 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
aaf9789c
Parents:
e3272101 (diff), 4805495 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merging with upstream/master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/asprintf.c

    re3272101 rd5a89a3  
    5151}
    5252
    53 int vprintf_size(const char *fmt, va_list args)
     53int vprintf_length(const char *fmt, va_list args)
    5454{
    5555        printf_spec_t ps = {
     
    6262}
    6363
    64 int printf_size(const char *fmt, ...)
     64int printf_length(const char *fmt, ...)
    6565{
    6666        va_list args;
    6767        va_start(args, fmt);
    68         int ret = vprintf_size(fmt, args);
     68        int ret = vprintf_length(fmt, args);
    6969        va_end(args);
    7070
     
    8686        va_list args2;
    8787        va_copy(args2, args);
    88         int ret = vprintf_size(fmt, args2);
     88        int ret = vsnprintf(NULL, 0, fmt, args2);
    8989        va_end(args2);
    9090
    9191        if (ret > 0) {
    92                 *strp = malloc(STR_BOUNDS(ret) + 1);
     92                *strp = malloc(ret + 1);
    9393                if (*strp == NULL)
    9494                        return -1;
    9595
    96                 vsnprintf(*strp, STR_BOUNDS(ret) + 1, fmt, args);
     96                vsnprintf(*strp, ret + 1, fmt, args);
    9797        }
    9898
Note: See TracChangeset for help on using the changeset viewer.