summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/line.c
diff options
context:
space:
mode:
Diffstat (limited to 'libsmartcols/src/line.c')
-rw-r--r--libsmartcols/src/line.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libsmartcols/src/line.c b/libsmartcols/src/line.c
index cab99c5..2289db0 100644
--- a/libsmartcols/src/line.c
+++ b/libsmartcols/src/line.c
@@ -136,7 +136,7 @@ int scols_line_alloc_cells(struct libscols_line *ln, size_t n)
DBG(LINE, ul_debugobj(ln, "alloc %zu cells", n));
- ce = realloc(ln->cells, n * sizeof(struct libscols_cell));
+ ce = reallocarray(ln->cells, n, sizeof(struct libscols_cell));
if (!ce)
return -errno;
@@ -505,6 +505,20 @@ int scols_line_refer_data(struct libscols_line *ln, size_t n, char *data)
}
/**
+ * scols_line_is_filled:
+ * @ln: a pointer to a struct libscols_line instance
+ * @n: number of the cell
+ *
+ * Returns: 0 or 1 if cell was already filled (note that NULL is also valid filler)
+ */
+int scols_line_is_filled(struct libscols_line *ln, size_t n)
+{
+ struct libscols_cell *ce = scols_line_get_cell(ln, n);
+
+ return ce ? ce->is_filled : 0;
+}
+
+/**
* scols_line_refer_column_data:
* @ln: a pointer to a struct libscols_line instance
* @cl: column, whose data is to be set