From b3ef39a33db4d5884bfd4554d623f86ea4e1217b Mon Sep 17 00:00:00 2001 From: cindytsai Date: Wed, 28 Aug 2024 16:21:37 -0500 Subject: [PATCH] Reset the state We need to free it because it resets the state of the Python functions tracked by libyt. The design of how API gets called is a bit weird. Will fix this in future update. --- example/quick-start/quick-start.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/example/quick-start/quick-start.cpp b/example/quick-start/quick-start.cpp index 81a7fd6d..05c77cba 100644 --- a/example/quick-start/quick-start.cpp +++ b/example/quick-start/quick-start.cpp @@ -43,15 +43,18 @@ int main(int argc, char* argv[]) { // Execute Python functions and activate Python entry points // ========================================================== if (yt_run_Function("print_hello_world") != YT_SUCCESS) { + fprintf(stderr, "ERROR: yt_run_Function failed!\n"); exit(EXIT_FAILURE); } if (yt_run_FunctionArguments("print_args", 3, "\'1\'", "2", "3.0") != YT_SUCCESS) { + fprintf(stderr, "ERROR: yt_run_FunctionArguments failed!\n"); exit(EXIT_FAILURE); } // Activate Python prompt if (yt_run_InteractiveMode("LIBYT_STOP") != YT_SUCCESS) { + fprintf(stderr, "ERROR: yt_run_InteractiveMode failed!\n"); exit(EXIT_FAILURE); } @@ -67,6 +70,12 @@ int main(int argc, char* argv[]) { exit(EXIT_FAILURE); } + // Free and reset the state + if (yt_free() != YT_SUCCESS) { + fprintf(stderr, "ERROR: yt_free() failed!\n"); + exit(EXIT_FAILURE); + } + // ======================================= // Finalize libyt // =======================================