Feh / nocache

minimize caching effects
BSD 2-Clause "Simplified" License
554 stars 53 forks source link

Function destroy() unused? #17

Closed pavlinux closed 11 years ago

pavlinux commented 11 years ago

Function nowhere not used? Reserved?

Feh commented 11 years ago

In line 22 its prototype is marked as

static void destroy(void) __attribute__((destructor));

So it will run when the program exits (with possibly unclosed fds, which we want to subject to the usual cache-freeing that would take place when closing a file).

pavlinux commented 11 years ago

With atexit() it could be done? It is not clear.

Feh commented 11 years ago

Quoting atexit(3):

Linux notes
    Since glibc 2.2.3, atexit() (and  on_exit(3))  can  be  used  within  a
    shared  library  to establish functions that are called when the shared
    library is unloaded.

So I’m guessing this should yield an equal code path. However, for symmetry reasons alone I like the constructor/destructor approach currently taken. So if there are no substantial arguments of one over the other, I’d leave it like it is now.