Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit da1a6d6

Browse files
Tan, Yew Waynephmccarty
authored andcommitted
Enforce clang-format code style
1 parent 6144b98 commit da1a6d6

1 file changed

Lines changed: 26 additions & 16 deletions

File tree

src/server.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,31 @@ int configure_urls(void)
108108
const char *token = env_var;
109109
int count = 0;
110110
char **urls_new = NULL;
111-
if (env_var) while (1) {
112-
int token_len = strcspn(token, " \t\n");
113-
if (token_len) {
114-
count++;
115-
urls_new = realloc(urls_new, count * sizeof(char*));
116-
if (!urls_new) { perror("realloc()"); exit(EXIT_FAILURE); }
117-
118-
char *url = calloc(token_len+1, sizeof(char));
119-
if (!url) { perror("calloc()"); exit(EXIT_FAILURE); }
120-
121-
urls_new[count-1] = strncpy(url, token, token_len);
122-
token += token_len;
111+
if (env_var) {
112+
while (1) {
113+
int token_len = strcspn(token, " \t\n");
114+
if (token_len) {
115+
count++;
116+
urls_new = realloc(urls_new, count * sizeof(char *));
117+
if (!urls_new) {
118+
perror("realloc()");
119+
exit(EXIT_FAILURE);
120+
}
121+
122+
char *url = calloc(token_len + 1, sizeof(char));
123+
if (!url) {
124+
perror("calloc()");
125+
exit(EXIT_FAILURE);
126+
}
127+
128+
urls_new[count - 1] = strncpy(url, token, token_len);
129+
token += token_len;
130+
}
131+
if (*token == '\0') {
132+
break;
133+
}
134+
token++;
123135
}
124-
if (*token == '\0') break;
125-
token++;
126136
}
127137
if (count) {
128138
// Abandon defaults
@@ -136,7 +146,7 @@ int configure_urls(void)
136146
void free_urls(void)
137147
{
138148
if (urls != urls_default) {
139-
for (int i=0; i<urls_size; i++) {
149+
for (int i = 0; i < urls_size; i++) {
140150
free(urls[i]);
141151
}
142152
free(urls);
@@ -467,7 +477,7 @@ int main(__nc_unused__ int argc, __nc_unused__ char **argv)
467477
} else {
468478
fprintf(stderr, "Using compiled default urls\n");
469479
}
470-
for (int i=0; i<urls_size; i++) {
480+
for (int i = 0; i < urls_size; i++) {
471481
fprintf(stderr, "url: %s\n", urls[i]);
472482
}
473483

0 commit comments

Comments
 (0)