assert(suffix);
a = strlen(s);
- if (b > ((size_t) -1) - a)
+ if (b > ((size_t) - 1) - a)
return NULL;
- r = new(char, a+b+1);
+ r = new(char, a + b + 1);
if (!r)
return NULL;
memcpy(r, s, a);
- memcpy(r+a, suffix, b);
- r[a+b] = 0;
+ memcpy(r + a, suffix, b);
+ r[a + b] = 0;
return r;
}
s += strspn(s, WHITESPACE);
- for (e = strchr(s, 0); e > s; e --)
+ for (e = strchr(s, 0); e > s; e--)
if (!strchr(WHITESPACE, e[-1]))
break;
return 0;
}
-bool nulstr_contains(const char*nulstr, const char *needle) {
+bool nulstr_contains(const char *nulstr, const char *needle) {
const char *i;
if (!nulstr)
return path;
}
-char* endswith(const char *s, const char *postfix) {
+char *endswith(const char *s, const char *postfix) {
size_t sl, pl;
assert(s);
pl = strlen(postfix);
if (pl == 0)
- return (char*) s + sl;
+ return (char *) s + sl;
if (sl < pl)
return NULL;
if (memcmp(s + sl - pl, postfix, pl) != 0)
return NULL;
- return (char*) s + sl - pl;
+ return (char *) s + sl - pl;
}
int parse_boolean(const char *v) {
return 0;
num_l = strspn(b, "0123456789");
- if (num_l < len-1)
+ if (num_l < len - 1)
return -EINVAL;
unit_l = strcspn(b, "BKMG");
if (!len)
return 0;
- if (string[len-1] != '%')
+ if (string[len - 1] != '%')
return -EINVAL;
num_len = strspn(string, "0123456789");
- if (num_len < len-1)
+ if (num_len < len - 1)
return -EINVAL;
num = strndup(string, num_len);
assert(separator);
assert(state);
- current = *state ? *state : (char*) c;
+ current = *state ? *state : (char *) c;
if (!*current || *c == 0)
return NULL;
separator_include_quotes = !!strspn(separator, QUOTES);
current += strspn(current, separator);
- while((s = strcspn(current + *l, separator))) {
+ while ((s = strcspn(current + *l, separator))) {
*l += s;
if (separator_include_quotes ||
quote_complete(current, *l))
*state = current + *l;
- return (char *)current;
+ return (char *) current;
}
bool is_number(const char *s, int l) {
if (l < 2)
return strdup(str);
- if (strchr(quotes, str[0]) &&
- str[0] == str[l-1])
- return strndup(str+1, l-2);
+ if (strchr(quotes, str[0]) && str[0] == str[l - 1])
+ return strndup(str + 1, l - 2);
return strdup(str);
}
STORE_RESET_ERRNO;
(void) fputs(str, f);
- if ((flags & FILE_WRITE_NEWLINE_IF_NOT) &&
- !endswith(str, "\n"))
+ if ((flags & FILE_WRITE_NEWLINE_IF_NOT) && !endswith(str, "\n"))
(void) fputc('\n', f);
if (flags & FILE_WRITE_WITH_FFLUSH)
return -ENOMEM;
}
- new = (char **)realloc(v, sizeof(char *) * (i + 2));
+ new = (char **) realloc(v, sizeof(char *) * (i + 2));
if (!new) {
free(p);
free(v);
v = new;
v[i] = p;
- v[i+1] = NULL;
+ v[i + 1] = NULL;
i++;
}
if (second) {
n2 = sizeof_strv(second);
- new = (char **)realloc(first, sizeof(char *) * (n1 + n2 + 1));
+ new = (char **) realloc(first, sizeof(char *) * (n1 + n2 + 1));
if (!new)
return -ENOMEM;
if (r < 0)
continue;
- if (strneq(pname, comm, TASK_COMM_LEN-1))
+ if (strneq(pname, comm, TASK_COMM_LEN - 1))
return atoi(de->d_name);
}
maps->n_map++;
- maps->maps = (struct smap **)realloc(
- maps->maps,
- sizeof(struct smap *) * maps->n_map);
+ maps->maps = (struct smap **) realloc(maps->maps, sizeof(struct smap *) * maps->n_map);
if (!maps->maps)
return -ENOMEM;
goto on_error;
}
- n = sscanf(buf, "%x-%x %ms %*s %*s %*s %ms",
- &map->start, &map->end, &map->mode, &map->name);
+ n = sscanf(buf, "%x-%x %ms %*s %*s %*s %ms", &map->start, &map->end, &map->mode, &map->name);
if (n == 3 && !map->name)
map->name = strdup("[anon]");
break;
}
- if ((*buf >= '0' && *buf <= '9') ||
- (*buf >= 'a' && *buf <= 'f')) {
+ if ((*buf >= '0' && *buf <= '9') || (*buf >= 'a' && *buf <= 'f')) {
get_line = false;
break;
}
return -errno;
if (remain_mask & MEMINFO_MASK_MEM_AVAILABLE)
- remain_mask |= (MEMINFO_MASK_MEM_FREE |
- MEMINFO_MASK_CACHED);
+ remain_mask |= (MEMINFO_MASK_MEM_FREE | MEMINFO_MASK_CACHED);
while (remain_mask) {
unsigned int v = 0;
}
if (remain_mask & MEMINFO_MASK_MEM_AVAILABLE) {
- mi->value[MEMINFO_ID_MEM_AVAILABLE] =
- mi->value[MEMINFO_ID_MEM_FREE]
+ mi->value[MEMINFO_ID_MEM_AVAILABLE] = mi->value[MEMINFO_ID_MEM_FREE]
+ mi->value[MEMINFO_ID_CACHED];
}