So far MuPDF source is very readable, I like it. But for some reason MuPDF doesn't have essential things you would normally expect from an open source project:
- no decent web site (current page doesn't count),
- no mailing list (well, there's fitz-dev, but it's basically dead - maybe crazy anti spam technique is to blame?),
- no documentation.
But, after some googling I found there was some documentation in now-not-working wiki.ghostscript.com. Fortunately, some information survived thanks to archive.org. It's very old (from 2004!), but it seems core concepts hasn't changes since then. Below are some extracts from the wiki, mostly about reference counting (that's what I am currently interested in).
Dynamic Objects:
The objects are reference counted. It is up to the creator of an object to drop it once it is no longer needed. Getting an element from an array or dictionary object does not modify the elements reference count, so if you need to hold on to the object for a longer amount of time, make damn sure you call keep on it.
Coding Style on memory allocation:
In general, when a function (verb) acts on an object or structure (noun), the name shall be fz_verbnoun. The following verbs shall be used consistently:
- new: for heap-allocating new objects.
- free: for destroying objects created by new. Alternate name: destroy
- keep: increment a refcnt.
- drop: decrement a refcnt.