]> Lady’s Gitweb - CGirls/commit
Document and improve `request.h´
authorLady <redacted>
Thu, 20 Mar 2025 03:59:56 +0000 (23:59 -0400)
committerLady <redacted>
Fri, 28 Mar 2025 17:44:02 +0000 (13:44 -0400)
commit259adc84f29a70aa2ba33f1eaa7f6a461bb51759
tree4a39581f358bc30acfcb26453208775f9abed826
parent2df68e839c93e66eed2cdd9f4027546c1210bb79
Document and improve `request.h´

Mostly, this commit just adds documentation comments to `request.h´ to
fully explain its behaviour, including renaming some things for
stylistic reasons. How·ever, it does make one significant change:

It reverts the definition of `cgirls_mtype´ and `cgirls_vb´ back to
enums.

Previously, I thought that it might be possible to be clever and
define these as `constexpr´ strings. That would enable them to be
serialized by string value and compared by pointer value, perhaps
offering the best of both worlds. And this worked in initial tests!

Unfortunately, `constexpr´ declarations have internal linkage, which
means that a ⹐different⹑ object is created for each translation unit
(file). This renders the existence of these `constexpr´s essentially
use·less in a header file, since nobody outside of `request.c´ will
have the same pointers that `request.c´ has.

(This C “feature” is presumably to help guarantee constancy, since
anything with `extern´ linkage cannot be truly guaranteed to be
constant.)

The new approach goes back to enums but provides `static const*const´
arrays which map those enums to string values. This of course means the
enums need to be roughly sequential, and one needs to check that a
given index is actually in bounds and does not point to `nullptr´
before using its associated value. Defining the enums as
`unsigned char´ at least means they can never be negative.
cgirls-test-pathinfo.c
request.c
request.h
This page took 0.053268 seconds and 4 git commands to generate.