/* Function: al_destroy_bitmap */ void al_destroy_bitmap(ALLEGRO_BITMAP *bitmap) { if (!bitmap) { return; } /* As a convenience, implicitly untarget the bitmap on the calling thread * before it is destroyed, but maintain the current display. */ if (bitmap == al_get_target_bitmap()) { ALLEGRO_DISPLAY *display = al_get_current_display(); if (display) al_set_target_bitmap(al_get_backbuffer(display)); else al_set_target_bitmap(NULL); } _al_set_bitmap_shader_field(bitmap, NULL); _al_unregister_destructor(_al_dtor_list, bitmap); if (!al_is_sub_bitmap(bitmap)) { ALLEGRO_DISPLAY* disp = _al_get_bitmap_display(bitmap); if (al_get_bitmap_flags(bitmap) & ALLEGRO_MEMORY_BITMAP) { destroy_memory_bitmap(bitmap); return; } /* Else it's a display bitmap */ if (bitmap->locked) al_unlock_bitmap(bitmap); if (bitmap->vt) bitmap->vt->destroy_bitmap(bitmap); if (disp) _al_vector_find_and_delete(&disp->bitmaps, &bitmap); if (bitmap->memory) al_free(bitmap->memory); } al_free(bitmap); }
/* Function: al_destroy_native_file_dialog */ void al_destroy_native_file_dialog(ALLEGRO_FILECHOOSER *dialog) { ALLEGRO_NATIVE_DIALOG *fd = (ALLEGRO_NATIVE_DIALOG *)dialog; size_t i; if (!fd) return; _al_unregister_destructor(_al_dtor_list, fd); al_ustr_free(fd->title); al_destroy_path(fd->fc_initial_path); for (i = 0; i < fd->fc_path_count; i++) { al_destroy_path(fd->fc_paths[i]); } al_free(fd->fc_paths); al_ustr_free(fd->fc_patterns); al_free(fd); }
/* Function: al_close_native_text_log */ void al_close_native_text_log(ALLEGRO_TEXTLOG *textlog) { ALLEGRO_NATIVE_DIALOG *dialog = (ALLEGRO_NATIVE_DIALOG *)textlog; if (!dialog) return; if (!dialog->tl_init_error) { dialog->tl_done = false; if (TEXT_LOG_EXTRA_THREAD) { al_lock_mutex(dialog->tl_text_mutex); _al_close_native_text_log(dialog); while (!dialog->tl_done) { al_wait_cond(dialog->tl_text_cond, dialog->tl_text_mutex); } } else { _al_close_native_text_log(dialog); al_lock_mutex(dialog->tl_text_mutex); } _al_unregister_destructor(_al_dtor_list, dialog); } al_ustr_free(dialog->title); al_ustr_free(dialog->tl_pending_text); al_destroy_user_event_source(&dialog->tl_events); al_unlock_mutex(dialog->tl_text_mutex); if (TEXT_LOG_EXTRA_THREAD) { al_destroy_thread(dialog->tl_thread); } al_destroy_cond(dialog->tl_text_cond); al_destroy_mutex(dialog->tl_text_mutex); al_free(dialog); }
/* Function: al_destroy_event_queue */ void al_destroy_event_queue(ALLEGRO_EVENT_QUEUE *queue) { ASSERT(queue); _al_unregister_destructor(_al_dtor_list, queue); /* Unregister any event sources registered with this queue. */ while (_al_vector_is_nonempty(&queue->sources)) { ALLEGRO_EVENT_SOURCE **slot = _al_vector_ref_back(&queue->sources); al_unregister_event_source(queue, *slot); } ASSERT(_al_vector_is_empty(&queue->sources)); _al_vector_free(&queue->sources); ASSERT(queue->events_head == queue->events_tail); _al_vector_free(&queue->events); _al_cond_destroy(&queue->cond); _al_mutex_destroy(&queue->mutex); al_free(queue); }
/* Function: al_destroy_bitmap */ void al_destroy_bitmap(ALLEGRO_BITMAP *bitmap) { if (!bitmap) { return; } _al_unregister_destructor(_al_dtor_list, bitmap); if (bitmap->parent) { /* It's a sub-bitmap */ if (bitmap->display) _al_vector_find_and_delete(&bitmap->display->bitmaps, &bitmap); al_free(bitmap); return; } if (bitmap->flags & ALLEGRO_MEMORY_BITMAP) { _al_destroy_memory_bitmap(bitmap); return; } /* Else it's a display bitmap */ if (bitmap->locked) al_unlock_bitmap(bitmap); if (bitmap->vt) bitmap->vt->destroy_bitmap(bitmap); if (bitmap->display) _al_vector_find_and_delete(&bitmap->display->bitmaps, &bitmap); if (bitmap->memory) al_free(bitmap->memory); al_free(bitmap); }
/* _al_kcm_unregister_destructor: * Unregister an object to be destroyed. */ void _al_kcm_unregister_destructor(_AL_LIST_ITEM *dtor_item) { _al_unregister_destructor(kcm_dtors, dtor_item); }