+/* Copies 'actions' into a newly allocated structure for use by 'flow'
+ * and frees the structure that defined the previous actions. */
+void flow_replace_acts(struct sw_flow *flow, const struct ofp_action *actions,
+ int n_actions)
+{
+ struct sw_flow_actions *sfa;
+ int size = sizeof *sfa + (n_actions * sizeof sfa->actions[0]);
+
+ sfa = malloc(size);
+ if (unlikely(!sfa))
+ return;
+
+ sfa->n_actions = n_actions;
+ memcpy(sfa->actions, actions, n_actions * sizeof sfa->actions[0]);
+
+ free(flow->sf_acts);
+ flow->sf_acts = sfa;
+
+ return;
+}
+