assert(data);
+ int ret = RESOURCED_ERROR_OUT_OF_MEMORY;
+ bool is_fg = !strcmp(result->name, CPU_SCHED_FG_NAME);
+ char *name = strdup(result->name);
+
struct coreset *c = (struct coreset *)calloc(1, sizeof *c);
- if (NULL == c)
- return RESOURCED_ERROR_OUT_OF_MEMORY;
+ if (NULL == c || NULL == name)
+ goto err_out;
- int r = cpu_sched_parse_cpuset(c, result->value);
- if (r < 0) {
+ c->name = name;
+
+ if (cpu_sched_parse_cpuset(c, result->value) < 0) {
_E("cpu-sched parse %s coreset: could not parse", result->name);
- return RESOURCED_ERROR_FAIL;
+ ret = RESOURCED_ERROR_FAIL;
+ goto err_out;
}
- if (strcmp(result->name, CPU_SCHED_FG_NAME)) { /* not a 'foreground' group */
- c->name = strdup(result->name);
- data->apps = g_slist_append(data->apps, c);
- } else {
- c->name = strdup(CPU_SCHED_FG_NAME);
+ if (is_fg)
data->fg = c;
- }
+ else
+ data->apps = g_slist_append(data->apps, c);
- return c->name ? RESOURCED_ERROR_NONE : RESOURCED_ERROR_OUT_OF_MEMORY;
+ return RESOURCED_ERROR_NONE;
+
+err_out:
+ free(c);
+ free(name);
+ return ret;
}
static int cpu_sched_parse_config(struct cpu_sched *data)