Posted on September 21, 2014

First version of mref_fetch_filename() opens a handle then hands it to mref_fetch_handle(). Now, what should the latter do with this handle? Clearly it needs to fflush and fsync it, and it almost might as well close it too. That was the first way I wrote it, and I liked the fact that the call from mref_fetch_filename() was in a tail position. It seems wrong for a function to close a handle that it didn’t open, but on the other hand it would be wrong for the caller to do anything more with that handle, after we’ve verified the hash. So, although it’s an odd interface, I’m going to stick with it.

It’s also occurred to me that I really do want to define macros for all the possible error conditions… made a start on that.

Now, I currently have:

typedef unsigned char *mref;
typedef int mref_field_t[MREF_NUM_FIELDS];

But that’s silly, because we need to keep these things together.