Part of my ongoing, hidden effort to port lighttpd to glib I can now at least say: it compiles.
Well, mostly. The core does compile and mod_staticfile is also mostly done. Mostly, as I don’t have decided on how to handle the config-file handling yet.
So, what has been done so far:
- buffer.c and buffer.h are gone and are replaced by GString
- array.c is gone and is replace by GHashTable or GPtrArray
- array.h will vanish when the data_…c goes away
- log.c is now a wrapper around g_log_…
As you see this is ripping out the basic data-structures and replaces them by a glib look-alike.
This isn’t just a drop-in replacement as the structures use other field-names and sometimes have a slightly different meaning.
One example is GString vs. buffer:
buffer { char *ptr; size_t used; size_t size; }; GString { char *str; size_t len; size_t allocated_len; };
While str and ptr, and allocated_len and size match, used and len differ by one byte (used includes the NUL-byte, len doesn’t).
One side-effect of this boring work is seeing the code-size shrinking, piece by piece.
Seeing old, sometimes dirty code vanish is another nice side-effect. Like the log_error_write() call … man …