These keep and drop calls for simple objects are generally implemented by using one of a set of standard functions. There are a range of these, depending on the expected size of the reference counts, and all handle the locking required to ensure thread safety:
As an example, a fz_path structure is defined as:
and thus appropriate keep and drop functions can be defined simply:
More complex variations of these functions are available to cope with ‘storable’ objects, and still more complex versions to cope with ‘key storable’ objects - these are explained in the following sections.
However they are implemented, these objects all look basically the same to most users - they can simply be ‘kept’ and ‘dropped’ as required.