Fix and enhance memory usage regarding log table
Found by: michaelortmann Patch by: michaelortmann Fixes:
One-line summary: Enhance memory usage regarding log table - Fix regression since eggdrop 1.9.0rc1
Additional description (if needed):
This PR not only fixes the regression since eggdrop 1.9.0rc1, but makes eggdrop even better than before regarding amount of memory allocation for log table
During eggdrop startup, memory for log tables is allocated:
https://github.com/eggheads/eggdrop/blob/341477a3fba56ec1b3f5a5b67fee3dec35878f2c/src/misc.c#L92-L101
about max-logs * LOGLINELEN bytes
default max-logs is 20
LOGLINELEN was rised from 1024 to 9000 since eggdrop 1.9.0rc1
20 * 9000 = 180 kbytes
Users probably raise max-logs to 100 or more in their configuration files so they wont have to care about it anymore, not aware of the memory usage implications.
This PR makes eggdrop to still allocate memory for max-logs log tables. but only about 56 bytes per table / logfile static. szlast (last log messages to track repeats) will be allocated (grow) dynamically until LOGLINELEN.
.status will now show the log table information, similar to socket table (and memory table, if debug enabled)
Add MIN() and MAX() to eggdrop.h
Test cases demonstrating functionality (if applicable):
$ grep max-logs BotA.conf
set max-logs 100
Before:
[michael@zen ~]$ ps u|grep egg
michael 861664 0.0 0.0 18556 13664 pts/4 S+ 04:41 0:00 ./eggdrop -t BotA.conf
After:
[michael@zen ~]$ ps u|grep egg
michael 862487 0.0 0.0 17668 12956 pts/4 S+ 04:42 0:00 ./eggdrop -t BotA.conf
.status
Log table: 1/100 5728 bytes