summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/line.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:32 +0000
commit8bb05ac73a5b448b339ce0bc8d396c82c459b47f (patch)
tree1fdda006866bca20d41cb206767ea5241e36852f /libsmartcols/src/line.c
parentAdding debian version 2.39.3-11. (diff)
downloadutil-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.tar.xz
util-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.zip
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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