table: add teble_add_string_cell()

This commit is contained in:
Yu Watanabe
2019-05-29 14:21:19 +09:00
parent f1bc253efa
commit 5896e03c6f
2 changed files with 15 additions and 0 deletions
+14
View File
@@ -380,6 +380,20 @@ int table_add_cell_full(
return 0;
}
int table_add_cell_stringf(Table *t, TableCell **ret_cell, const char *format, ...) {
_cleanup_free_ char *buffer = NULL;
va_list ap;
int r;
va_start(ap, format);
r = vasprintf(&buffer, format, ap);
va_end(ap);
if (r < 0)
return -ENOMEM;
return table_add_cell(t, ret_cell, TABLE_STRING, buffer);
}
int table_dup_cell(Table *t, TableCell *cell) {
size_t i;
+1
View File
@@ -36,6 +36,7 @@ int table_add_cell_full(Table *t, TableCell **ret_cell, TableDataType type, cons
static inline int table_add_cell(Table *t, TableCell **ret_cell, TableDataType type, const void *data) {
return table_add_cell_full(t, ret_cell, type, data, (size_t) -1, (size_t) -1, (unsigned) -1, (unsigned) -1, (unsigned) -1);
}
int table_add_cell_stringf(Table *t, TableCell **ret_cell, const char *format, ...) _printf_(3, 4);
int table_dup_cell(Table *t, TableCell *cell);