@@ 58,6 58,7 @@ fn write_index(index: []package, f: io::handle) void = {
fn free_all(packages: []package) void = {
for (let i = 0z; i < len(packages); i += 1) {
strings::freeall(packages[i].props);
+ free(packages[i].name);
};
free(packages);
};
@@ 95,14 96,18 @@ export fn main() void = {
let new_packages = read_index(os::stdin_file)!;
defer free_all(new_packages);
+ let all_packages: []package = [];
+ defer free(all_packages);
+ append(all_packages, base_packages...);
+
for (let i = 0z; i < len(new_packages); i += 1) {
- match (index(base_packages, new_packages[i].name)) {
+ match (index(all_packages, new_packages[i].name)) {
case let idx: size =>
- base_packages[idx] = new_packages[i];
+ all_packages[idx] = new_packages[i];
case =>
- append(base_packages, new_packages[i]);
+ append(all_packages, new_packages[i]);
};
};
- write_index(base_packages, os::stdout);
+ write_index(all_packages, os::stdout);
};