loci: add of_object_truncate

This code is taken from IVS which will eventually use the loci version. When
we're reusing an of_object multiple times to reduce the number of allocations,
and we're appending to it, we have to reset its length to the original to
prevent it from growing forever.
diff --git a/c_gen/templates/of_object.c b/c_gen/templates/of_object.c
index fafaab5..3836728 100644
--- a/c_gen/templates/of_object.c
+++ b/c_gen/templates/of_object.c
@@ -599,3 +599,16 @@
 
     return OF_ERROR_NONE;
 }
+
+/*
+ * Truncate an object to its initial length.
+ *
+ * This allows the caller to reuse a single allocated object even if
+ * it has been appended to.
+ */
+void
+of_object_truncate(of_object_t *obj)
+{
+    of_object_init_map[obj->object_id](obj, obj->version, -1, 0);
+    obj->wbuf->current_bytes = obj->length;
+}
diff --git a/c_gen/templates/of_object.h b/c_gen/templates/of_object.h
index 0ca415b..804e7ec 100644
--- a/c_gen/templates/of_object.h
+++ b/c_gen/templates/of_object.h
@@ -100,6 +100,8 @@
 
 void of_object_parent_length_update(of_object_t *obj, int delta);
 
+void of_object_truncate(of_object_t *obj);
+
 struct of_object_s {
     /** A pointer to the underlying buffer's management structure. */
     of_wire_buffer_t *wbuf;