示例#1
0
/**
 * scols_copy_symbols:
 * @sb: a pointer to a struct libscols_symbols instance
 *
 * Returns: a newly allocated copy of the @sb symbol group or NULL in caes of an error.
 */
struct libscols_symbols *scols_copy_symbols(const struct libscols_symbols *sb)
{
	struct libscols_symbols *ret;
	int rc;

	assert(sb);
	if (!sb)
		return NULL;

	ret = scols_new_symbols();
	if (!ret)
		return NULL;

	rc = scols_symbols_set_branch(ret, sb->branch);
	if (!rc)
		rc = scols_symbols_set_vertical(ret, sb->vert);
	if (!rc)
		rc = scols_symbols_set_right(ret, sb->right);
	if (!rc)
		rc = scols_symbols_set_title_padding(ret, sb->title_padding);
	if (!rc)
		return ret;

	scols_unref_symbols(ret);
	return NULL;

}
示例#2
0
/**
 * scols_unref_table:
 * @tb: a pointer to a struct libscols_table instance
 *
 * Decreases the refcount of @tb.
 */
void scols_unref_table(struct libscols_table *tb)
{
	if (tb && (--tb->refcount <= 0)) {
		scols_table_remove_lines(tb);
		scols_table_remove_columns(tb);
		scols_unref_symbols(tb->symbols);
		free(tb->linesep);
		free(tb->colsep);
		free(tb);
	}
}
示例#3
0
/**
 * scols_unref_table:
 * @tb: a pointer to a struct libscols_table instance
 *
 * Decreases the refcount of @tb. When the count falls to zero, the instance
 * is automatically deallocated.
 */
void scols_unref_table(struct libscols_table *tb)
{
	if (tb && (--tb->refcount <= 0)) {
		DBG(TAB, ul_debugobj(tb, "dealloc"));
		scols_table_remove_lines(tb);
		scols_table_remove_columns(tb);
		scols_unref_symbols(tb->symbols);
		free(tb->linesep);
		free(tb->colsep);
		free(tb);
	}
}