/* Release all memory acquired by this allocator. */ static void gs_heap_free_all(gs_memory_t * mem, uint free_mask, client_name_t cname) { gs_malloc_memory_t *const mmem = (gs_malloc_memory_t *) mem; gx_monitor_t *mon = mmem->monitor; /* * We don't perform locking during this process since the 'monitor' * is contained in this allocator, and will get freed along the way. * It is only called at exit, and there better not be any threads * accessing this allocator. */ mmem->monitor = NULL; /* delete reference to this monitor */ gx_monitor_free(mon); /* free the monitor */ if (free_mask & FREE_ALL_DATA) { gs_malloc_block_t *bp = mmem->allocated; gs_malloc_block_t *np; for (; bp != 0; bp = np) { np = bp->next; if_debug3('a', "[a]gs_heap_free_all(%s) 0x%lx(%u)\n", client_name_string(bp->cname), (ulong) (bp + 1), bp->size); gs_alloc_fill(bp + 1, gs_alloc_fill_free, bp->size); free(bp); } } if (free_mask & FREE_ALL_ALLOCATOR) free(mem); }
/* Dnitialize a gx_page_queue object */ void gx_page_queue_dnit( gx_page_queue_t * queue /* page queue to dnit */ ) { /* Deallocate any left-over queue entries */ gx_page_queue_entry_t *entry; while ((entry = gx_page_queue_remove_first(queue)) != 0) { gx_page_queue_entry_free_page_info(entry); gx_page_queue_entry_free(entry); } /* Free dynamic objects */ if (queue->monitor) { gx_monitor_free(queue->monitor); queue->monitor = 0; } if (queue->render_req_sema) { gx_semaphore_free(queue->render_req_sema); queue->render_req_sema = 0; } if (queue->render_done_sema) { gx_semaphore_free(queue->render_done_sema); queue->render_done_sema = 0; } if (queue->reserve_entry) { gx_page_queue_entry_free(queue->reserve_entry); queue->reserve_entry = 0; } }
/* release the semaphore and monitor of the link_cache when it is freed */ void icc_linkcache_finalize(const gs_memory_t *mem, void *ptr) { gsicc_link_cache_t *link_cache = (gsicc_link_cache_t * ) ptr; gx_semaphore_free(link_cache->wait); link_cache->wait = NULL; gx_monitor_free(link_cache->lock); link_cache->lock = NULL; }
static void rc_gsicc_link_cache_free(gs_memory_t * mem, void *ptr_in, client_name_t cname) { /* Ending the entire cache. The ref counts on all the links should be 0 */ gsicc_link_cache_t *link_cache = (gsicc_link_cache_t * ) ptr_in; while (link_cache->head != NULL) { gsicc_remove_link(link_cache->head, mem); link_cache->num_links--; } #ifdef DEBUG if (link_cache->num_links != 0) { eprintf1("num_links is %d, should be 0.\n", link_cache->num_links); } #endif gx_semaphore_free(link_cache->wait); link_cache->wait = NULL; gx_monitor_free(link_cache->lock); link_cache->lock = NULL; if_debug2(gs_debug_flag_icc,"[icc] Removing link cache = 0x%x memory = 0x%x\n", link_cache, link_cache->memory); gs_free_object(mem->stable_memory, link_cache, "rc_gsicc_link_cache_free"); }