create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)

{

    size_t *sizes = calloc(nr_iov, sizeof(size_t));

    size_t count = 0;

    void *buf = NULL;

    void *p;

    int i;



    for (i = 0; i < nr_iov; i++) {

        char *arg = argv[i];

        int64_t len;



        len = cvtnum(arg);

        if (len < 0) {

            printf("non-numeric length argument -- %s\n", arg);

            goto fail;

        }



        /* should be SIZE_T_MAX, but that doesn't exist */

        if (len > INT_MAX) {

            printf("too large length argument -- %s\n", arg);

            goto fail;

        }



        if (len & 0x1ff) {

            printf("length argument %" PRId64

                   " is not sector aligned\n", len);

            goto fail;

        }



        sizes[i] = len;

        count += len;

    }



    qemu_iovec_init(qiov, nr_iov);



    buf = p = qemu_io_alloc(count, pattern);



    for (i = 0; i < nr_iov; i++) {

        qemu_iovec_add(qiov, p, sizes[i]);

        p += sizes[i];

    }



fail:

    free(sizes);

    return buf;

}

create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)

{

    size_t *sizes = calloc(nr_iov, sizeof(size_t));

    size_t count = 0;

    void *buf = NULL;

    void *p;

    int i;



    for (i = 0; i < nr_iov; i++) {

        char *arg = argv[i];

        int64_t len;



        len = cvtnum(arg);

        if (len < 0) {

            printf("non-numeric length argument -- %s\n", arg);

            goto fail;

        }



        

        if (len > INT_MAX) {

            printf("too large length argument -- %s\n", arg);

            goto fail;

        }



        if (len & 0x1ff) {

            printf("length argument %" PRId64

                   " is not sector aligned\n", len);

            goto fail;

        }



        sizes[i] = len;

        count += len;

    }



    qemu_iovec_init(qiov, nr_iov);



    buf = p = qemu_io_alloc(count, pattern);



    for (i = 0; i < nr_iov; i++) {

        qemu_iovec_add(qiov, p, sizes[i]);

        p += sizes[i];

    }



fail:

    free(sizes);

    return buf;

}

FUNC_0(QEMUIOVector *VAR_0, char **VAR_1, int VAR_2, int VAR_3)

{

    size_t *sizes = calloc(VAR_2, sizeof(size_t));

    size_t count = 0;

    void *VAR_4 = NULL;

    void *VAR_5;

    int VAR_6;



    for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {

        char *VAR_7 = VAR_1[VAR_6];

        int64_t len;



        len = cvtnum(VAR_7);

        if (len < 0) {

            printf("non-numeric length argument -- %s\n", VAR_7);

            goto fail;

        }



        

        if (len > INT_MAX) {

            printf("too large length argument -- %s\n", VAR_7);

            goto fail;

        }



        if (len & 0x1ff) {

            printf("length argument %" PRId64

                   " is not sector aligned\n", len);

            goto fail;

        }



        sizes[VAR_6] = len;

        count += len;

    }



    qemu_iovec_init(VAR_0, VAR_2);



    VAR_4 = VAR_5 = qemu_io_alloc(count, VAR_3);



    for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {

        qemu_iovec_add(VAR_0, VAR_5, sizes[VAR_6]);

        VAR_5 += sizes[VAR_6];

    }



fail:

    free(sizes);

    return VAR_4;

}

FUNC_0(QEMUIOVector *VAR_0, char **VAR_1, int VAR_2, int VAR_3)
{ size_t *sizes = calloc(VAR_2, sizeof(size_t)); size_t count = 0; void *VAR_4 = NULL; void *VAR_5; int VAR_6; for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) { char *VAR_7 = VAR_1[VAR_6]; int64_t len; len = cvtnum(VAR_7); if (len < 0) { printf("non-numeric length argument -- %s\n", VAR_7); goto fail; } if (len > INT_MAX) { printf("too large length argument -- %s\n", VAR_7); goto fail; } if (len & 0x1ff) { printf("length argument %" PRId64
" is not sector aligned\n", len); goto fail; } sizes[VAR_6] = len; count += len; } qemu_iovec_init(VAR_0, VAR_2); VAR_4 = VAR_5 = qemu_io_alloc(count, VAR_3); for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) { qemu_iovec_add(VAR_0, VAR_5, sizes[VAR_6]); VAR_5 += sizes[VAR_6]; } fail:
free(sizes); return VAR_4; }