diff options
author | irungentoo <irungentoo@tox.im> | 2014-02-09 09:27:50 -0500 |
---|---|---|
committer | irungentoo <irungentoo@tox.im> | 2014-02-09 09:27:50 -0500 |
commit | c498c206ed8eb2bd24031ddbe10956ff8bc9a82d (patch) | |
tree | ca7ff20c531951eea055a93f7a9a7ad274fa57e5 /testing/experiment/group_chats_test1.c | |
parent | 7f977f9ad2fd4fdbfc1aec2081909da38cf601e9 (diff) | |
parent | 3782213b6e2731a29110e940546aa8981efad08b (diff) |
Merge pull request #720 from nurupo/master
Fixed some memory leaks
Diffstat (limited to 'testing/experiment/group_chats_test1.c')
-rw-r--r-- | testing/experiment/group_chats_test1.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/testing/experiment/group_chats_test1.c b/testing/experiment/group_chats_test1.c index a74f808a..fc10ab64 100644 --- a/testing/experiment/group_chats_test1.c +++ b/testing/experiment/group_chats_test1.c | |||
@@ -1,4 +1,6 @@ | |||
1 | #include "../../toxcore/group_chats.h" | 1 | #include "../../toxcore/group_chats.h" |
2 | #include "../misc_tools.c" // hex_string_to_bin | ||
3 | |||
2 | #define NUM_CHATS 8 | 4 | #define NUM_CHATS 8 |
3 | 5 | ||
4 | #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) | 6 | #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) |
@@ -54,19 +56,6 @@ void print_group(Group_Chat *chat) | |||
54 | } | 56 | } |
55 | } | 57 | } |
56 | 58 | ||
57 | unsigned char *hex_string_to_bin(char hex_string[]) | ||
58 | { | ||
59 | size_t len = strlen(hex_string); | ||
60 | unsigned char *val = malloc(len); | ||
61 | char *pos = hex_string; | ||
62 | int i; | ||
63 | |||
64 | for (i = 0; i < len; ++i, pos += 2) | ||
65 | sscanf(pos, "%2hhx", &val[i]); | ||
66 | |||
67 | return val; | ||
68 | } | ||
69 | |||
70 | void print_message(Group_Chat *chat, int peer_number, uint8_t *message, uint16_t length, void *userdata) | 59 | void print_message(Group_Chat *chat, int peer_number, uint8_t *message, uint16_t length, void *userdata) |
71 | { | 60 | { |
72 | printf("%u: %s | %u\n", peer_number, message, length); | 61 | printf("%u: %s | %u\n", peer_number, message, length); |
@@ -95,8 +84,12 @@ int main(int argc, char *argv[]) | |||
95 | * bootstrap_ip_port.ip.c[2] = 0; | 84 | * bootstrap_ip_port.ip.c[2] = 0; |
96 | * bootstrap_ip_port.ip.c[3] = 1; */ | 85 | * bootstrap_ip_port.ip.c[3] = 1; */ |
97 | bootstrap_ip_port.ip.uint32 = inet_addr(argv[1]); | 86 | bootstrap_ip_port.ip.uint32 = inet_addr(argv[1]); |
87 | |||
88 | uint8_t *bootstrap_id = hex_string_to_bin(argv[3]); | ||
98 | 89 | ||
99 | chat_bootstrap(chat, bootstrap_ip_port, hex_string_to_bin(argv[3])); | 90 | chat_bootstrap(chat, bootstrap_ip_port, bootstrap_id); |
91 | |||
92 | free(bootstrap_id); | ||
100 | 93 | ||
101 | while (1) { | 94 | while (1) { |
102 | 95 | ||