projects
/
project
/
procd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d6d146f
)
remove outer memdup
author
Felix Fietkau
<nbd@openwrt.org>
Mon, 25 Jun 2012 19:07:35 +0000
(21:07 +0200)
committer
Felix Fietkau
<nbd@openwrt.org>
Mon, 25 Jun 2012 19:07:35 +0000
(21:07 +0200)
service.c
patch
|
blob
|
history
diff --git
a/service.c
b/service.c
index
56e0feb
..
da7ec9b
100644
(file)
--- a/
service.c
+++ b/
service.c
@@
-53,10
+53,17
@@
static struct service *
service_alloc(const char *name)
{
struct service *s;
service_alloc(const char *name)
{
struct service *s;
+ char *new_name;
+
+ s = calloc(1, sizeof(*s) + strlen(name) + 1);
+
+ new_name = (char *) s + 1;
+ strcpy(new_name, name);
- s = calloc(1, sizeof(*s));
vlist_init(&s->instances, avl_strcmp, service_instance_update);
s->instances.keep_old = true;
vlist_init(&s->instances, avl_strcmp, service_instance_update);
s->instances.keep_old = true;
+ s->name = new_name;
+ s->avl.key = s->name;
return s;
}
return s;
}
@@
-78,15
+85,9
@@
static const struct blobmsg_policy service_set_attrs[__SERVICE_SET_MAX] = {
static int
service_update(struct service *s, struct blob_attr *config, struct blob_attr **tb)
{
static int
service_update(struct service *s, struct blob_attr *config, struct blob_attr **tb)
{
- struct blob_attr *old_config = s->config;
struct blob_attr *cur;
int rem;
struct blob_attr *cur;
int rem;
- /* only the pointer changes, the content stays the same,
- * no avl update necessary */
- s->name = s->avl.key = blobmsg_data(tb[SERVICE_SET_NAME]);
- s->config = config;
-
if (tb[SERVICE_SET_INSTANCES]) {
vlist_update(&s->instances);
blobmsg_for_each_attr(cur, tb[SERVICE_SET_INSTANCES], rem) {
if (tb[SERVICE_SET_INSTANCES]) {
vlist_update(&s->instances);
blobmsg_for_each_attr(cur, tb[SERVICE_SET_INSTANCES], rem) {
@@
-95,8
+96,6
@@
service_update(struct service *s, struct blob_attr *config, struct blob_attr **t
vlist_flush(&s->instances);
}
vlist_flush(&s->instances);
}
- free(old_config);
-
return 0;
}
return 0;
}
@@
-129,10
+128,6
@@
service_handle_set(struct ubus_context *ctx, struct ubus_object *obj,
const char *name;
int ret = UBUS_STATUS_INVALID_ARGUMENT;
const char *name;
int ret = UBUS_STATUS_INVALID_ARGUMENT;
- msg = blob_memdup(msg);
- if (!msg)
- return UBUS_STATUS_UNKNOWN_ERROR;
-
blobmsg_parse(service_set_attrs, __SERVICE_SET_MAX, tb, blob_data(msg), blob_len(msg));
cur = tb[SERVICE_ATTR_NAME];
if (!cur)
blobmsg_parse(service_set_attrs, __SERVICE_SET_MAX, tb, blob_data(msg), blob_len(msg));
cur = tb[SERVICE_ATTR_NAME];
if (!cur)