Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor() {
this.env = [];
let count_and_size = changetype(
new ArrayBuffer(2 * sizeof())
);
let ret = environ_sizes_get(count_and_size, count_and_size + 4);
if (ret != errno.SUCCESS) {
abort();
}
let count = load(count_and_size);
let size = load(count_and_size + sizeof());
let env_ptrs = changetype(
new ArrayBuffer((count + 1) * sizeof())
);
let buf = changetype(new ArrayBuffer(size));
if (environ_get(env_ptrs, buf) != errno.SUCCESS) {
abort();
}
for (let i: usize = 0; i < count; i++) {
let env_ptr = load(env_ptrs + i * sizeof());
let env_ptr_split = StringUtils.fromCString(env_ptr).split("=", 2);
let key = env_ptr_split[0];
let value = env_ptr_split[1];
this.env.push(new EnvironEntry(key, value));
}
}
constructor() {
this.args = [];
let count_and_size = changetype(
new ArrayBuffer(2 * sizeof())
);
let ret = args_sizes_get(count_and_size, count_and_size + 4);
if (ret != errno.SUCCESS) {
abort();
}
let count = load(count_and_size);
let size = load(count_and_size + sizeof());
let env_ptrs = changetype(
new ArrayBuffer((count + 1) * sizeof())
);
let buf = changetype(new ArrayBuffer(size));
if (args_get(env_ptrs, buf) != errno.SUCCESS) {
abort();
}
for (let i: usize = 0; i < count; i++) {
let env_ptr = load(env_ptrs + i * sizeof());
let arg = StringUtils.fromCString(env_ptr);
this.args.push(arg);
}