Skip to content

Commit

Permalink
remove pthread support
Browse files Browse the repository at this point in the history
  • Loading branch information
Trumeet committed Oct 11, 2021
1 parent 84fce72 commit 251be34
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 20 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Easy-to-use helpers for TDLib JSON.

* json-c

* pthread (if you compile with `TG_ENABLE_PTHREAD`)

## Functions

* Automatically handles authorization state changes.
Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -ex
cc -o easy-td.o -std=c99 -I. -DTG_ENABLE_PTHREAD -DTG_DEBUG -fsanitize=address -rdynamic -O0 -g3 -c easy-tg.c
cc -o easy-td.o -std=c99 -I. -DTG_DEBUG -fsanitize=address -rdynamic -O0 -g3 -c easy-tg.c
cc -o example.o -std=c99 -I. -DAPI_ID=114514 -DAPI_HASH="\"hhhhhAAAAA\"" -fsanitize=address -rdynamic -O0 -g3 -c example.c
cc -o example -std=c99 -lpthread -ltdjson -ljson-c -fsanitize=address easy-td.o example.o
17 changes: 0 additions & 17 deletions easy-tg.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ const void *tg_reg4 = NULL;
const void *tg_reg5 = NULL;
const void *tg_reg6 = NULL;

#ifdef TG_ENABLE_PTHREAD
#include <pthread.h>
static pthread_mutex_t mutex_close = PTHREAD_MUTEX_INITIALIZER;
#endif

json_object *tg_mkreq(const char *extra, const char *type, const char *args_key, json_object *args)
{
json_object *root = json_object_new_object();
Expand Down Expand Up @@ -233,18 +228,12 @@ int tg_init()

int tg_destroy()
{
#ifdef TG_ENABLE_PTHREAD
pthread_mutex_lock(&mutex_close);
#endif
if(td == NULL)
{
return 0;
}
td_json_client_destroy(td);
td = NULL;
#ifdef TG_ENABLE_PTHREAD
pthread_mutex_unlock(&mutex_close);
#endif
return 0;
}

Expand Down Expand Up @@ -287,14 +276,8 @@ int tg_loop()

int tg_close()
{
#ifdef TG_ENABLE_PTHREAD
pthread_mutex_lock(&mutex_close);
#endif
if(td == NULL) return 0;
/* Using json object seems to be leaking */
tg_send_raw(false, "{ \"@type\": \"close\" }");
#ifdef TG_ENABLE_PTHREAD
pthread_mutex_unlock(&mutex_close);
#endif
return 0;
}

0 comments on commit 251be34

Please sign in to comment.