ovsdb-idl: Fix use-after-free error in ovsdb_idl_txn_delete().
[openvswitch] / lib / ovsdb-data.h
index b31aa5d496f07d10ed0cdd0af2ba3f2f58787d31..6ee5f9ac06b894fd03f7f83774bfc741ad82e911 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009 Nicira Networks
+/* Copyright (c) 2009, 2010 Nicira Networks
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ union ovsdb_atom {
 };
 
 void ovsdb_atom_init_default(union ovsdb_atom *, enum ovsdb_atomic_type);
+bool ovsdb_atom_is_default(const union ovsdb_atom *, enum ovsdb_atomic_type);
 void ovsdb_atom_clone(union ovsdb_atom *, const union ovsdb_atom *,
                       enum ovsdb_atomic_type);
 void ovsdb_atom_swap(union ovsdb_atom *, union ovsdb_atom *);
@@ -72,7 +73,21 @@ struct ovsdb_error *ovsdb_atom_from_json(union ovsdb_atom *,
 struct json *ovsdb_atom_to_json(const union ovsdb_atom *,
                                 enum ovsdb_atomic_type);
 \f
-/* One value of an OVSDB type (given by struct ovsdb_type). */
+/* An instance of an OVSDB type (given by struct ovsdb_type).
+ *
+ * 'n' is constrained by the ovsdb_type's 'n_min' and 'n_max'.
+ *
+ * If 'n' is nonzero, then 'keys' points to an array of 'n' atoms of the type
+ * specified by the ovsdb_type's 'key_type'.  (Otherwise, 'keys' should be
+ * null.)
+ *
+ * If 'n' is nonzero and the ovsdb_type's 'value_type' is not OVSDB_TYPE_VOID,
+ * then 'values' points to an array of 'n' atoms of the type specified by the
+ * 'value_type'.  (Otherwise, 'values' should be null.)
+ *
+ * Thus, for 'n' > 0, 'keys' will always be nonnull and 'values' will be
+ * nonnull only for "map" types.
+ */
 struct ovsdb_datum {
     unsigned int n;             /* Number of 'keys' and 'values'. */
     union ovsdb_atom *keys;     /* Each of the ovsdb_type's 'key_type'. */
@@ -80,10 +95,14 @@ struct ovsdb_datum {
 };
 
 void ovsdb_datum_init_default(struct ovsdb_datum *, const struct ovsdb_type *);
+bool ovsdb_datum_is_default(const struct ovsdb_datum *,
+                            const struct ovsdb_type *);
 void ovsdb_datum_clone(struct ovsdb_datum *, const struct ovsdb_datum *,
                        const struct ovsdb_type *);
 void ovsdb_datum_destroy(struct ovsdb_datum *, const struct ovsdb_type *);
 void ovsdb_datum_swap(struct ovsdb_datum *, struct ovsdb_datum *);
+struct ovsdb_error *ovsdb_datum_sort(struct ovsdb_datum *,
+                                     const struct ovsdb_type *);
 
 struct ovsdb_error *ovsdb_datum_from_json(struct ovsdb_datum *,
                                           const struct ovsdb_type *,
@@ -108,6 +127,14 @@ bool ovsdb_datum_excludes_all(const struct ovsdb_datum *,
                               const struct ovsdb_datum *,
                               const struct ovsdb_type *);
 
+void ovsdb_datum_union(struct ovsdb_datum *,
+                       const struct ovsdb_datum *,
+                       const struct ovsdb_type *);
+void ovsdb_datum_subtract(struct ovsdb_datum *a,
+                          const struct ovsdb_type *a_type,
+                          const struct ovsdb_datum *b,
+                          const struct ovsdb_type *b_type);
+
 static inline bool
 ovsdb_datum_conforms_to_type(const struct ovsdb_datum *datum,
                              const struct ovsdb_type *type)