You are checking file->dirty twice, first before calling the function and within the function too. Same for the Assert. For example.
size_t
BufFileRead(BufFile *file, void *ptr, size_t size)
{
size_t nread = 0;
size_t nthistime;
if (file->dirty)
{
BufFileFlush(file);
Assert(!file->dirty);
}
static void
BufFileFlush(BufFile *file)
{
if (file->dirty)
BufFileDumpBuffer(file);
Assert(!file->dirty);
The new status of this patch is: Waiting on Author