@@ -608,26 +608,24 @@ int set_aes_ivt(const char *ivt)
char** string_split(const char* in, const char d)
{
- char** result = 0;
- size_t count = 0;
+ char** result = 0;
+ size_t count = 0;
char* last_delim = 0;
char delim[2];
delim[0] = d;
delim[1] = 0;
char *s = strdup(in);
- char* tmp = s;
+ char* tmp = s;
if (!s)
return NULL;
/* Count how many elements will be extracted. */
- while (*tmp)
- {
- if (d == *tmp)
- {
- count++;
- last_delim = tmp;
- }
- tmp++;
+ while (*tmp) {
+ if (d == *tmp) {
+ count++;
+ last_delim = tmp;
+ }
+ tmp++;
}
/* Add space for trailing token. */
@@ -639,17 +637,15 @@ char** string_split(const char* in, const char d)
result = malloc(sizeof(char*) * count);
- if (result)
- {
- size_t idx = 0;
- char* token = strtok(s, delim);
-
- while (token)
- {
- *(result + idx++) = strdup(token);
- token = strtok(0, delim);
- }
- *(result + idx) = 0;
+ if (result) {
+ size_t idx = 0;
+ char* token = strtok(s, delim);
+
+ while (token) {
+ *(result + idx++) = strdup(token);
+ token = strtok(0, delim);
+ }
+ *(result + idx) = 0;
}
free(s);
Sanitize formatting of the string_split() function. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- core/util.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-)