Skip to content

Commit

Permalink
Simplify Examples
Browse files Browse the repository at this point in the history
- Put the static th_server variable inside the main function.
  • Loading branch information
RaphiaRa committed Sep 29, 2024
1 parent c41852d commit c900a08
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions examples/echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <stdlib.h>
#include <string.h>

static th_server* server = NULL;
static bool running = true;

static void sigint_handler(int signum)
Expand Down Expand Up @@ -61,7 +60,7 @@ int main(int argc, char** argv)
(void)argc;
(void)argv;
signal(SIGINT, sigint_handler);

th_server* server = NULL;
th_err err = TH_ERR_OK;
if ((err = th_server_create(&server, NULL)) != TH_ERR_OK)
goto cleanup;
Expand Down
3 changes: 1 addition & 2 deletions examples/file_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <stdlib.h>
#include <string.h>

static th_server* server = NULL;
static bool running = true;

static void
Expand Down Expand Up @@ -75,7 +74,7 @@ int main(int argc, char** argv)
print_help();
return EXIT_FAILURE;
}

th_server* server = NULL;
th_err err = TH_ERR_OK;
if ((err = th_server_create(&server, NULL)) != TH_ERR_OK)
goto cleanup;
Expand Down
3 changes: 1 addition & 2 deletions examples/hello_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <stdlib.h>
#include <string.h>

static th_server* server = NULL;
static bool running = true;

static void
Expand All @@ -30,7 +29,7 @@ int main(int argc, char** argv)
(void)argc;
(void)argv;
signal(SIGINT, sigint_handler);

th_server* server = NULL;
th_err err = TH_ERR_OK;
if ((err = th_server_create(&server, NULL)) != TH_ERR_OK)
goto cleanup;
Expand Down

0 comments on commit c900a08

Please sign in to comment.