]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: be sure column is unused
authorKarel Zak <kzak@redhat.com>
Mon, 18 Jan 2016 09:36:31 +0000 (10:36 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 18 Jan 2016 09:36:31 +0000 (10:36 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/table.c

index 3360d525bc88c0683420143350ddcb631be8dfa6..ca1e64825a89f431f4d1ce48564e2abdafc5a3c5 100644 (file)
@@ -126,13 +126,14 @@ int scols_table_set_name(struct libscols_table *tb, const char *name)
  * @tb: a pointer to a struct libscols_table instance
  * @cl: a pointer to a struct libscols_column instance
  *
- * Adds @cl to @tb's column list.
+ * Adds @cl to @tb's column list. The column cannot be shared between more
+ * tables.
  *
  * Returns: 0, a negative number in case of an error.
  */
 int scols_table_add_column(struct libscols_table *tb, struct libscols_column *cl)
 {
-       if (!tb || !cl || !list_empty(&tb->tb_lines))
+       if (!tb || !cl || !list_empty(&tb->tb_lines) || cl->table)
                return -EINVAL;
 
        if (cl->flags & SCOLS_FL_TREE)