After reading Daniel Stenberg's post on case-insensitive string comparison in cURL, I decided to take a stab at implementing something like this in Lwan for the same reasons. (Lwan used to use strcasecmp() before using the one described in this blog post.) Published September, 15, 2022
One of the decisions I took early on while writing Lwan was to only support Linux, and think about portability later; this decision was influenced by the way the OpenBSD project approaches portability. Published June, 28, 2018
A pretty common mistake that happens when programming things in C is to allocate less memory than necessary to hold a structure: Published May, 01, 2015
I've been thinking for a while on how to reduce the overhead in Lwan's string buffer, when the strings are small. There are a number of ways of accomplishing this. Published November, 02, 2014
There are various ways to convert integers to their string representation. These conversions are rarely a bottleneck, but they often show up while profiling certain applications. For instance, they're very common in Lwan while building the response… Published June, 23, 2014
One of the things that bothers me when I'm writing software is that I never get things right the first time. It takes me quite a few iterations to achieve a good result -- be it performance, memory usage, or a good architecture. Getting things to a "good… Published December, 08, 2013
There are some functions in the standard C library that takes a function pointer to be used as a callback later on. Examples include atexit() and signal(). However, these functions can't receive an arbitrary pointer (which could hold some important… Published July, 20, 2013
Writing asynchronous I/O code in C is kind of tedious, and often leads to a callback hell. But it doesn’t have to be this way; if you have a main loop, it’s quite simple to use coroutines and write code in a soothing, old school, synchronous way. Published September, 29, 2012
Golang has a lot of nice features – and one I found pretty interesting is called deferred statements. This can be implemented in C++ pretty easily through RAII, but in C we’re pretty much out of luck. Or are we? Published August, 11, 2012
C’s switch statement is very powerful. However, it can’t be used with strings, only with constant integral types. This is understandable, since strings in C are merely arrays – they’re not first-class citizens. Published August, 09, 2012