diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2017-02-08 14:34:48 +0100 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2017-02-08 14:34:48 +0100 |
commit | c259669fa33ca13b5c6ae60eb8ffa0874ddc01b2 (patch) | |
tree | 09003c2fa4d614b1e4f1fb10d16fba21acb56b4d /nest/a-set.c | |
parent | 82f42ea09176afdb67ab119258d714e8c8e54d12 (diff) | |
parent | da65a3d898fde0ce567782d86919a66e29916ed7 (diff) |
Merge branch 'master' into int-new
Diffstat (limited to 'nest/a-set.c')
-rw-r--r-- | nest/a-set.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/nest/a-set.c b/nest/a-set.c index 82bf8b0d..a2fb6953 100644 --- a/nest/a-set.c +++ b/nest/a-set.c @@ -233,6 +233,26 @@ lc_set_contains(struct adata *list, lcomm val) return 0; } +struct adata * +int_set_prepend(struct linpool *pool, struct adata *list, u32 val) +{ + struct adata *res; + int len; + + if (int_set_contains(list, val)) + return list; + + len = list ? list->length : 0; + res = lp_alloc(pool, sizeof(struct adata) + len + 4); + res->length = len + 4; + + if (list) + memcpy(res->data + 4, list->data, list->length); + + * (u32 *) res->data = val; + + return res; +} struct adata * int_set_add(struct linpool *pool, struct adata *list, u32 val) @@ -250,8 +270,7 @@ int_set_add(struct linpool *pool, struct adata *list, u32 val) if (list) memcpy(res->data, list->data, list->length); - u32 *c = (u32 *) (res->data + len); - *c = val; + * (u32 *) (res->data + len) = val; return res; } |