Closed fmor closed 11 months ago
It seems to me that dmon.h:1202 will free space in the _dmon.watches
buffer by swapping the removed element with the last element. So as soon as you unwatch ids[0]
, ids[5]
becomes invalid as 5 is stored in 0 now. It seems a lot like a bug to me. As a workaround, I guess you could remove all three of those (windows, linux,mac) from dmon.h and you'd be fine as long as you don't create more than a total of DMON_MAX_WATCHES
(64) throughout the lifetime of your program.
Thinking about how to actually solve this: Is there a good reason to not just heap-allocate each dmon__watch_state individually and include a pointer to it in dmon__watch_state?
sorry for a "little bit of delay" in response :D. I totally missed this thread. Anyways, I took a new approach using freelists, and it should be fixed now. Although haven't tested it that much, if there is any regression bugs, please feel free to re-open this.
Hi,
First, thanks for sharing your work. Maybe i missed something in the documentation but dmon raise an assert when unwatching dirs in the same order that they were supplied, maybe will happen if unwatching randomly too. Below is a small test programm to illustrate this behaviour.