11.4 Reference counting

In common with most other objects in MuPDF, fz_display_lists are reference counted. This means that once you have finished with a reference to a display list, it can safely be disposed of by calling fz_drop_display_list.

/* 
   fz_drop_display_list: Drop a reference to a display list, freeing it 
   if the reference count reaches zero. 
 
   Does not throw exceptions. 
*/ 
void fz_drop_display_list(fz_context *ctx, fz_display_list *list);

Should you wish to keep a new reference to a display list, you can generate one using fz_keep_display_list.

/* 
   fz_keep_display_list: Keep a reference to a display list. 
 
   Does not throw exceptions. 
*/ 
fz_display_list *fz_keep_display_list(fz_context *ctx, fz_display_list *list);

In general, it is rare for you to want to make a new reference to a display list until write operations on one have finished. It is good form to avoid this.