Consolidate code for (bytevector)

This commit is contained in:
Justin Ethier 2016-03-23 22:01:08 -04:00
parent 29f49d9704
commit d3f1e7a1ca

View file

@ -1418,29 +1418,7 @@ object Cyc_make_bytevector(void *data, object cont, int argc, object len, ...) {
}
void dispatch_bytevector(void *data, int _argc, object clo, object cont, object bval, ...) {
int argc = _argc - 1;
int i = 0, val;
va_list ap;
object tmp;
char *buffer;
make_empty_bytevector(bv);
if (argc > 0) {
Cyc_check_int(data, bval);
buffer = alloca(sizeof(char) * argc);
val = obj_is_int(bval) ? obj_obj2int(bval) : integer_value(bval);
buffer[i] = val;
va_start(ap, bval);
for(i = 1; i < argc; i++) {
tmp = va_arg(ap, object);
Cyc_check_int(data, tmp);
val = obj_is_int(tmp) ? obj_obj2int(tmp) : integer_value(tmp);
buffer[i] = (unsigned char) val;
}
va_end(ap);
bv.len = argc;
bv.data = buffer;
}
return_closcall1(data, cont, &bv);
Cyc_bytevector_va_list((_argc - 1));
}
object Cyc_bytevector(void *data, object cont, int _argc, object bval, ...) {