This function will acquire its first user in an upcoming commit.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
/* Initializes 'dst' as a copy of 'src'.
*
- * The caller must eventually destroy 'rule' with cls_rule_destroy(). */
+ * The caller must eventually destroy 'dst' with cls_rule_destroy(). */
void
cls_rule_clone(struct cls_rule *dst, const struct cls_rule *src)
{
dst->priority = src->priority;
}
+/* Initializes 'dst' with the data in 'src', destroying 'src'.
+ *
+ * The caller must eventually destroy 'dst' with cls_rule_destroy(). */
+void
+cls_rule_move(struct cls_rule *dst, struct cls_rule *src)
+{
+ minimatch_move(&dst->match, &src->match);
+ dst->priority = src->priority;
+}
+
/* Frees memory referenced by 'rule'. Doesn't free 'rule' itself (it's
* normally embedded into a larger structure).
*
/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void cls_rule_init_from_minimatch(struct cls_rule *, const struct minimatch *,
unsigned int priority);
void cls_rule_clone(struct cls_rule *, const struct cls_rule *);
+void cls_rule_move(struct cls_rule *dst, struct cls_rule *src);
void cls_rule_destroy(struct cls_rule *);
bool cls_rule_equal(const struct cls_rule *, const struct cls_rule *);
memcpy(dst->values, src->values, n * sizeof *dst->values);
}
+/* Initializes 'dst' with the data in 'src', destroying 'src'.
+ * The caller must eventually free 'dst' with miniflow_destroy(). */
+void
+miniflow_move(struct miniflow *dst, struct miniflow *src)
+{
+ int n = miniflow_n_values(src);
+ if (n <= MINI_N_INLINE) {
+ dst->values = dst->inline_values;
+ memcpy(dst->values, src->values, n * sizeof *dst->values);
+ } else {
+ dst->values = src->values;
+ }
+ memcpy(dst->map, src->map, sizeof dst->map);
+}
+
/* Frees any memory owned by 'flow'. Does not free the storage in which 'flow'
* itself resides; the caller is responsible for that. */
void
miniflow_clone(&dst->masks, &src->masks);
}
+/* Initializes 'dst' with the data in 'src', destroying 'src'.
+ * The caller must eventually free 'dst' with minimask_destroy(). */
+void
+minimask_move(struct minimask *dst, struct minimask *src)
+{
+ miniflow_clone(&dst->masks, &src->masks);
+}
+
/* Initializes 'dst_' as the bit-wise "and" of 'a_' and 'b_'.
*
* The caller must provide room for FLOW_U32S "uint32_t"s in 'storage', for use
void miniflow_init(struct miniflow *, const struct flow *);
void miniflow_clone(struct miniflow *, const struct miniflow *);
+void miniflow_move(struct miniflow *dst, struct miniflow *);
void miniflow_destroy(struct miniflow *);
void miniflow_expand(const struct miniflow *, struct flow *);
void minimask_init(struct minimask *, const struct flow_wildcards *);
void minimask_clone(struct minimask *, const struct minimask *);
+void minimask_move(struct minimask *dst, struct minimask *src);
void minimask_combine(struct minimask *dst,
const struct minimask *a, const struct minimask *b,
uint32_t storage[FLOW_U32S]);
minimask_clone(&dst->mask, &src->mask);
}
+/* Initializes 'dst' with the data in 'src', destroying 'src'. The caller must
+ * eventually free 'dst' with minimatch_destroy(). */
+void
+minimatch_move(struct minimatch *dst, struct minimatch *src)
+{
+ miniflow_move(&dst->flow, &src->flow);
+ minimask_move(&dst->mask, &src->mask);
+}
+
/* Frees any memory owned by 'match'. Does not free the storage in which
* 'match' itself resides; the caller is responsible for that. */
void
/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void minimatch_init(struct minimatch *, const struct match *);
void minimatch_clone(struct minimatch *, const struct minimatch *);
+void minimatch_move(struct minimatch *dst, struct minimatch *src);
void minimatch_destroy(struct minimatch *);
void minimatch_expand(const struct minimatch *, struct match *);