Index: trunk/debs/squid/redirector.c |
— | — | @@ -54,8 +54,7 @@ |
55 | 55 | char buff[MAX_BUFF]; |
56 | 56 | setbuf(stdout, NULL); |
57 | 57 | |
58 | | - struct IN_BUFF *in_buff = NULL; |
59 | | - in_buff = (struct IN_BUFF *)malloc(sizeof(struct IN_BUFF)); |
| 58 | + struct IN_BUFF in_buff; |
60 | 59 | pattern = "^http:\\/\\/(\\w+)\\.wikipedia\\.org[:\\d]*\\/(.*)"; |
61 | 60 | pcre_extra *pe; |
62 | 61 | |
— | — | @@ -81,17 +80,17 @@ |
82 | 81 | |
83 | 82 | while(fgets(buff, MAX_BUFF, stdin) != NULL) { |
84 | 83 | |
85 | | - if (load_in_buff(buff, in_buff) != 0) { |
| 84 | + if (load_in_buff(buff, &in_buff) != 0) { |
86 | 85 | fprintf(stderr, "Error loading data %s\n", buff); |
87 | 86 | continue; |
88 | 87 | } |
89 | 88 | |
90 | | - subject_length = (int)strlen(in_buff->url); |
| 89 | + subject_length = (int)strlen(in_buff.url); |
91 | 90 | |
92 | 91 | rc = pcre_exec( |
93 | 92 | re, /* the compiled pattern */ |
94 | 93 | pe, /* no extra data - we didn't study the pattern */ |
95 | | - in_buff->url, /* the subject string */ |
| 94 | + in_buff.url, /* the subject string */ |
96 | 95 | subject_length, /* the length of the subject */ |
97 | 96 | 0, /* start at offset 0 in the subject */ |
98 | 97 | 0, /* default options */ |
— | — | @@ -101,7 +100,7 @@ |
102 | 101 | if (rc < 0) { |
103 | 102 | switch(rc) { |
104 | 103 | case PCRE_ERROR_NOMATCH: |
105 | | - printf("%s\n", in_buff->url); |
| 104 | + printf("%s\n", in_buff.url); |
106 | 105 | fflush(stdout); |
107 | 106 | |
108 | 107 | break; |
— | — | @@ -117,7 +116,7 @@ |
118 | 117 | |
119 | 118 | for (i = 0; i < rc; i++) { |
120 | 119 | |
121 | | - char *substring_start = in_buff->url + ovector[2*i]; |
| 120 | + char *substring_start = in_buff.url + ovector[2*i]; |
122 | 121 | int substring_length = ovector[2*i+1] - ovector[2*i]; |
123 | 122 | if (i == 1) { |
124 | 123 | if (substring_length >= sizeof(lang)) { |