aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/codegen
diff options
context:
space:
mode:
authorJ08nY2023-02-21 10:33:36 +0100
committerJ08nY2023-02-21 10:33:36 +0100
commit8c3f50503153ecdea17d7b52812a4419c6dfbf0f (patch)
treeb11e8b931c29abae3f10ecf3c698427b499d452f /pyecsca/codegen
parente52dd224e63425136fe112cb6c6b7c3b576d1ee4 (diff)
downloadpyecsca-codegen-8c3f50503153ecdea17d7b52812a4419c6dfbf0f.tar.gz
pyecsca-codegen-8c3f50503153ecdea17d7b52812a4419c6dfbf0f.tar.zst
pyecsca-codegen-8c3f50503153ecdea17d7b52812a4419c6dfbf0f.zip
Separate init and deinit from the main function.
Diffstat (limited to 'pyecsca/codegen')
-rw-r--r--pyecsca/codegen/templates/main.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/pyecsca/codegen/templates/main.c b/pyecsca/codegen/templates/main.c
index 2c1ce22..7854961 100644
--- a/pyecsca/codegen/templates/main.c
+++ b/pyecsca/codegen/templates/main.c
@@ -559,8 +559,8 @@ static uint8_t cmd_set_trigger(uint8_t *data, uint16_t len) {
return 0;
}
-int main(void) {
- // Initalize the platform, UART, triggers.
+void init(void) {
+ // Initalize the platform, UART, triggers.
platform_init();
init_uart();
trigger_setup();
@@ -574,6 +574,18 @@ int main(void) {
curve = curve_new();
pubkey = point_new();
bn_init(&privkey);
+}
+
+void deinit(void) {
+ // Clear up allocated stuff.
+ bn_clear(&privkey);
+ curve_free(curve);
+ point_free(pubkey);
+ formulas_clear();
+}
+
+int main(void) {
+ init();
// Add the SimpleSerial commands.
simpleserial_init();
@@ -600,10 +612,6 @@ int main(void) {
while(simpleserial_get());
//led_ok(0);
- // Clear up allocated stuff.
- bn_clear(&privkey);
- curve_free(curve);
- point_free(pubkey);
- formulas_clear();
+ deinit();
return 0;
-} \ No newline at end of file
+}