File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,6 +221,19 @@ struct table *table_init(void)
221221 return t ;
222222}
223223
224+ struct table * table_init_with_columns (struct table_column * c , int num_columns )
225+ {
226+ struct table * t = table_init ();
227+
228+ if (t ) {
229+ if (!table_add_columns (t , c , num_columns ))
230+ return t ;
231+ table_free (t );
232+ }
233+
234+ return NULL ;
235+ }
236+
224237static int table_add_column (struct table * t , struct table_column * c )
225238{
226239 struct table_column * new_columns ;
Original file line number Diff line number Diff line change @@ -146,4 +146,16 @@ void table_add_row(struct table *t, int row);
146146void table_print (struct table * t );
147147void table_free (struct table * t );
148148
149+ /**
150+ * table_init_with_columns() - Allocate a table instance with column definitions
151+ * @c: Column definitions
152+ * @num_columns:Number of columns
153+ *
154+ * This is a function combined table_init() and table_add_columns().
155+ *
156+ * Return: The table instance, or NULL if unsuccessful. If allocated, the caller
157+ * is responsible to free the table.
158+ */
159+ struct table * table_init_with_columns (struct table_column * c , int num_columns );
160+
149161#endif /* _TABLE_H_ */
You can’t perform that action at this time.
0 commit comments