Support large opds result listings without an OOM

This commit is contained in:
jpirnay
2026-05-10 18:03:47 +02:00
parent 7dcd433fe6
commit c4b94737fd
4 changed files with 118 additions and 50 deletions
+3 -14
View File
@@ -2,6 +2,7 @@
#include <Print.h>
#include <expat.h>
#include <functional>
#include <string>
#include <vector>
@@ -73,24 +74,13 @@ class OpdsParser final : public Print {
operator bool() { return !error(); }
/**
* Get the parsed entries (both navigation and book entries).
* @return Vector of OpdsEntry entries
*/
const std::vector<OpdsEntry>& getEntries() const& { return entries; }
std::vector<OpdsEntry> getEntries() && { return std::move(entries); }
/**
* Get only book entries (legacy compatibility).
* @return Vector of book entries
*/
std::vector<OpdsEntry> getBooks() const;
/**
* Clear all parsed entries.
*/
void clear();
std::function<void(OpdsEntry)> onEntryParsed;
private:
// Expat callbacks
static void XMLCALL startElement(void* userData, const XML_Char* name, const XML_Char** atts);
@@ -105,7 +95,6 @@ class OpdsParser final : public Print {
static const char* findAttribute(const XML_Char** atts, const char* name);
XML_Parser parser = nullptr;
std::vector<OpdsEntry> entries;
OpdsEntry currentEntry;
std::string currentText;