summaryrefslogtreecommitdiff
path: root/other/DHT_bootstrap.c
diff options
context:
space:
mode:
authorKonstantin Kowalski <kostyakow42@gmail.com>2013-07-26 16:16:58 -0400
committerKonstantin Kowalski <kostyakow42@gmail.com>2013-07-26 16:16:58 -0400
commita1b93c397c8776e1bb07e3e01110d0ee5b9d31b9 (patch)
tree2b0c2d136f0e06b2daa50ade33b046b52bc5655d /other/DHT_bootstrap.c
parent2bbffc9ca02be91ce4e5fa766bffef6241f1b303 (diff)
took out several strlen() calls out of the loop; replaced int's with size_t where needed
Diffstat (limited to 'other/DHT_bootstrap.c')
-rw-r--r--other/DHT_bootstrap.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index 9d94fecc..8942c237 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -41,12 +41,14 @@
41 41
42#define PORT 33445 42#define PORT 33445
43 43
44//TODO: rewrite
44unsigned char * hex_string_to_bin(char hex_string[]) 45unsigned char * hex_string_to_bin(char hex_string[])
45{ 46{
46 unsigned char * val = malloc(strlen(hex_string)); 47 size_t len = strlen(hex_string);
48 unsigned char * val = malloc(len);
47 char * pos = hex_string; 49 char * pos = hex_string;
48 int i=0; 50 int i=0;
49 while(i < strlen(hex_string)) 51 while(i < len)
50 { 52 {
51 sscanf(pos,"%2hhx",&val[i]); 53 sscanf(pos,"%2hhx",&val[i]);
52 pos+=2; 54 pos+=2;
@@ -139,4 +141,4 @@ int main(int argc, char *argv[])
139 } 141 }
140 shutdown_networking(); 142 shutdown_networking();
141 return 0; 143 return 0;
142} \ No newline at end of file 144}