void ymd_final(struct ymd_mach *vm) { gc_final(vm); kpool_final(vm); vm_final_context(vm); if (vm->pcre_js) pcre_jit_stack_free(vm->pcre_js); assert (vm->gc.used == 0); // Must free all memory! assert (vm->gc.n_alloced == 0); // Allocated object must be zero. free(vm); }
void xyzsh_final() { xyzsh_editline_final(); mcurses_final(); load_final(); run_final(); gc_final(); stack_end_stack(); stack_final(); }
int main(int argc, char **argv) { struct lsh_decode_key_options *options = make_lsh_decode_key_options(); struct lsh_string *input; struct lsh_string *output; int out = STDOUT_FILENO; argp_parse(&main_argp, argc, argv, 0, NULL, options); if (options->file) { out = open(lsh_get_cstring(options->file), O_WRONLY | O_CREAT, 0666); if (out < 0) { werror("Failed to open file `%S' for writing: %e.\n", options->file, errno); return EXIT_FAILURE; } } input = io_read_file_raw(STDIN_FILENO, 3000); if (!input) { werror("Failed to read stdin: %e.\n", errno); return EXIT_FAILURE; } if (options->base64) { if (!lsh_string_base64_decode(input)) { werror("Invalid base64 encoding.\n"); lsh_string_free(input); return EXIT_FAILURE; } } output = lsh_decode_key(input); lsh_string_free(input); if (!output) { werror("Invalid ssh2 key.\n"); return EXIT_FAILURE; } if (!write_raw(out, STRING_LD(output))) { werror("Write failed: %e.\n", errno); return EXIT_FAILURE; } lsh_string_free(output); gc_final(); return EXIT_SUCCESS; }