[libc-commits] [libc] [libc] Support dynamically-grown lines in FlatFileDatabase (PR #223811)
Alexey Samsonov via libc-commits
libc-commits at lists.llvm.org
Tue Sep 15 15:50:27 PDT 2026
================
@@ -16,27 +16,37 @@
#include "hdr/errno_macros.h"
#include "hdr/stdio_macros.h"
+#include "hdr/types/off_t.h"
#include "hdr/types/size_t.h"
#include "src/__support/CPP/functional.h"
+#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/span.h"
#include "src/__support/File/file.h"
#include "src/__support/error_or.h"
#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
+#include "src/__support/pwd/dynamic_buffer.h"
namespace LIBC_NAMESPACE_DECL {
namespace pwd {
+// Struct to hold the result of a line read operation.
struct ReadLineResult {
size_t bytes_read;
+ size_t raw_bytes_consumed;
bool truncated;
- // True only when no data was read because the file stream reached EOF.
+ // True only when zero bytes were read because the stream was already at EOF.
+ // A final line without a trailing newline returns bytes_read > 0 and
+ // eof == false; the following call returns bytes_read == 0 and eof == true.
bool eof;
};
-// Forward declaration of record parser for flat database files.
+// Parses a record in place and fills entry.
+// If the buffer is too small for auxiliary structures (such as pointer arrays),
+// specializations must return Error(ERANGE) prior to modifying the buffer.
template <typename EntryType>
-bool parse_line(cpp::span<char> line, EntryType *entry);
+ErrorOr<void> parse_line(cpp::span<char> buffer, size_t line_len,
----------------
vonosmas wrote:
I don't see why you need an extra "line_len" argument here - in both cases where this function is called, you can just take `.first()` items from the span.
https://github.com/llvm/llvm-project/pull/223811
More information about the libc-commits
mailing list