Skip to content

Commit

Permalink
cli: free allocated resources once cmd done
Browse files Browse the repository at this point in the history
  • Loading branch information
bonedaddy committed Nov 12, 2020
1 parent 2cea5a1 commit 374a0e6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ void gen_key_callback(int argc, char *argv[]) {
}
// generate the actual ecdsa key
ecdsa_private_key_t *pk = assert_new_ecdsa_private_key();
// save the ecdsa key in pem format at path
int rc = libp2p_crypto_ecdsa_private_key_save(pk, (char *)*pem_file_path->sval);
if (rc != 0) {
printf("failed to save ecdsa key\n");
return;
}
printf("generated ecdsa key and saved to %s\n", (char *)*pem_file_path->sval);
} else {
printf("generated ecdsa key and saved to %s\n", (char *)*pem_file_path->sval);
}
// free up memory allocated to pk struct
libp2p_crypto_ecdsa_free(pk);
}

void test_server_callback(int argc, char *argv[]) {
Expand Down

0 comments on commit 374a0e6

Please sign in to comment.