diff options
author | rofl0r <rofl0r@users.noreply.github.com> | 2020-09-05 19:32:21 +0100 |
---|---|---|
committer | rofl0r <rofl0r@users.noreply.github.com> | 2020-09-05 19:42:34 +0100 |
commit | 233ce6de3b4a23f44c0e8a1acdc76cc98be00358 (patch) | |
tree | fd44a597f56b7be28851b6772c61ab059d4f0b6a /src/vector.h | |
parent | c4dc3ba007fe34d6b7704ffb5ec812a436c326e7 (diff) |
filter: reduce memory usage, fix OOM crashes
* check return values of memory allocation and abort gracefully
in out-of-memory situations
* use sblist (linear dynamic array) instead of linked list
- this removes one pointer per filter rule
- removes need to manually allocate/free every single list item
(instead block allocation is used)
- simplifies code
* remove storage of (unused) input rule
- removes one char* pointer per filter rule
- removes storage of the raw bytes of each filter rule
* add line number to display on out-of-memory/invalid regex situation
* replace duplicate filter_domain()/filter_host() code with a single
function filter_run()
- reduces code size and management effort
with these improvements, >1 million regex rules can be loaded with
4 GB of RAM, whereas previously it crashed with about 950K.
the list for testing was assembled from
http://www.shallalist.de/Downloads/shallalist.tar.gz
closes #20
Diffstat (limited to 'src/vector.h')
0 files changed, 0 insertions, 0 deletions