struct cgroup *cgroup_new_cgroup(const char *name)
{
- struct cgroup *cgroup = (struct cgroup *)
- malloc(sizeof(struct cgroup));
+ struct cgroup *cgroup = calloc(1, sizeof(struct cgroup));
if (!cgroup)
return NULL;
return NULL;
}
- controller = (struct cgroup_controller *)
- malloc(sizeof(struct cgroup_controller));
+ controller = calloc(1, sizeof(struct cgroup_controller));
if (!controller)
return NULL;
const char *name, const char *value)
{
int i;
- struct control_value *cntl_value = (struct control_value *)
- malloc(sizeof(struct control_value));
-
- if (!cntl_value)
- return ECGCONTROLLERCREATEFAILED;
+ struct control_value *cntl_value;
if (controller->index >= CG_VALUE_MAX)
return ECGMAXVALUESEXCEEDED;
return ECGVALUEEXISTS;
}
+ cntl_value = calloc(1, sizeof(struct control_value));
+
+ if (!cntl_value)
+ return ECGCONTROLLERCREATEFAILED;
strncpy(cntl_value->name, name, sizeof(cntl_value->name));
strncpy(cntl_value->value, value, sizeof(cntl_value->value));
{
int i;
unsigned ret;
- struct control_value *cntl_value = (struct control_value *)
- malloc(sizeof(struct control_value));
-
- if (!cntl_value)
- return ECGCONTROLLERCREATEFAILED;
-
+ struct control_value *cntl_value;
if (controller->index >= CG_VALUE_MAX)
return ECGMAXVALUESEXCEEDED;
return ECGVALUEEXISTS;
}
+ cntl_value = calloc(1, sizeof(struct control_value));
+
+ if (!cntl_value)
+ return ECGCONTROLLERCREATEFAILED;
+
strncpy(cntl_value->name, name,
sizeof(cntl_value->name));
ret = snprintf(cntl_value->value,
{
int i;
unsigned ret;
- struct control_value *cntl_value = (struct control_value *)
- malloc(sizeof(struct control_value));
-
- if (!cntl_value)
- return ECGCONTROLLERCREATEFAILED;
-
+ struct control_value *cntl_value;
if (controller->index >= CG_VALUE_MAX)
return ECGMAXVALUESEXCEEDED;
return ECGVALUEEXISTS;
}
+ cntl_value = calloc(1, sizeof(struct control_value));
+
+ if (!cntl_value)
+ return ECGCONTROLLERCREATEFAILED;
+
strncpy(cntl_value->name, name, sizeof(cntl_value->name));
ret = snprintf(cntl_value->value, sizeof(cntl_value->value), "%lu",
value);
{
int i;
unsigned ret;
- struct control_value *cntl_value = (struct control_value *)
- malloc(sizeof(struct control_value));
-
- if (!cntl_value)
- return ECGCONTROLLERCREATEFAILED;
-
+ struct control_value *cntl_value;
if (controller->index >= CG_VALUE_MAX)
return ECGMAXVALUESEXCEEDED;
return ECGVALUEEXISTS;
}
+ cntl_value = calloc(1, sizeof(struct control_value));
+
+ if (!cntl_value)
+ return ECGCONTROLLERCREATEFAILED;
+
strncpy(cntl_value->name, name, sizeof(cntl_value->name));
if (value)