Commit bc280f82 authored by Mark Adler's avatar Mark Adler

Avoid the use of variable length arrays.

Microsoft has not implemented and refuses to implement C99 aspects
that are not also part of C++11 or later C++ standards. (Note that
the "99" in C99 refers to 1999. That was the year my younger son
was born, who is now applying for college.)
parent 4079828f
......@@ -1003,8 +1003,9 @@ local unsigned put(int out, ...) {
}
va_end(ap);
/* allocate memory on the stack for the data */
unsigned char wrap[count], *next = wrap;
/* allocate memory for the data */
unsigned char *wrap = alloc(NULL, count);
unsigned char *next = wrap;
/* write the requested data to wrap[] */
va_start(ap, out);
......@@ -1017,17 +1018,18 @@ local unsigned put(int out, ...) {
*next++ = val >> n;
} while (n);
}
else { /* little endian */
else /* little endian */
do {
*next++ = val;
val >>= 8;
} while (--n);
}
}
va_end(ap);
/* write wrap[] to out and return the number of bytes written */
return writen(out, wrap, count);
writen(out, wrap, count);
free(wrap);
return count;
}
/* Low 32-bits set to all ones. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment