/** * @brief Free any memory associated with a scheduler_t. * * This will stop the interface if it is currently running, and free all the * memory associated with the different regular expression and similar * structures. * * @param scheduler */ void scheduler_destroy(scheduler_t* scheduler) { // TODO interface close // TODO repo close event_loop_destroy(); if(scheduler->main_log) { log_destroy(scheduler->main_log); main_log = NULL; } if(scheduler->process_name) g_free(scheduler->process_name); if(scheduler->sysconfig) fo_config_free(scheduler->sysconfig); if(scheduler->sysconfigdir) g_free(scheduler->sysconfigdir); if(scheduler->host_queue) g_list_free(scheduler->host_queue); if(scheduler->workers) g_thread_pool_free(scheduler->workers, FALSE, TRUE); if(scheduler->email_subject) g_free(scheduler->email_subject); if(scheduler->email_command) g_free(scheduler->email_command); g_sequence_free(scheduler->job_queue); g_regex_unref(scheduler->parse_agent_msg); g_regex_unref(scheduler->parse_db_email); g_regex_unref(scheduler->parse_interface_cmd); g_tree_unref(scheduler->meta_agents); g_tree_unref(scheduler->agents); g_tree_unref(scheduler->host_list); g_tree_unref(scheduler->job_list); g_free(scheduler); }
void clientmgr_reomve_outdate_client(gulong inactive_time_allowed, void (*removethis)(Client * client) ) { time_t cutime; time(&cutime); gboolean remove_outdate(gpointer key, Client * client, GTree * newtree) { if( client->remove_outdate && ( (cutime - client->last_active_time) > inactive_time_allowed)) { removethis(client); }else { //add the unit to new tree g_tree_insert(newtree,g_memdup(key,6),g_object_ref(client)); } return FALSE; } g_static_rw_lock_writer_lock(&lock); GTree * oldclient_tree = client_tree; clientmgr_init(); g_tree_foreach(oldclient_tree,(GTraverseFunc)remove_outdate,client_tree); g_tree_unref(oldclient_tree); g_static_rw_lock_writer_unlock(&lock); }
/** * g_tree_destroy: * @tree: a #GTree * * Removes all keys and values from the #GTree and decreases its * reference count by one. If keys and/or values are dynamically * allocated, you should either free them first or create the #GTree * using g_tree_new_full(). In the latter case the destroy functions * you supplied will be called on all keys and values before destroying * the #GTree. */ void g_tree_destroy (GTree *tree) { g_return_if_fail (tree != NULL); g_tree_remove_all (tree); g_tree_unref (tree); }
/** * pka_subscription_destroy: * @subscription: A #PkaSubscription. * * Destroy handler when the reference count has reached zero. * * Returns: None. * Side effects: Armageddon. */ static void pka_subscription_destroy (PkaSubscription *subscription) /* IN */ { g_return_if_fail(subscription != NULL); ENTRY; g_tree_unref(subscription->channels); g_tree_unref(subscription->sources); g_tree_unref(subscription->manifests); if (subscription->manifest_closure) { g_closure_unref(subscription->manifest_closure); } if (subscription->sample_closure) { g_closure_unref(subscription->sample_closure); } if (subscription->encoder) { g_object_unref(subscription->encoder); } EXIT; }
static void g_keyfile_settings_backend_keyfile_reload (GKeyfileSettingsBackend *kfsb) { guint8 digest[32]; gchar *contents; gsize length; contents = NULL; length = 0; g_file_load_contents (kfsb->file, NULL, &contents, &length, NULL, NULL); compute_checksum (digest, contents, length); if (memcmp (kfsb->digest, digest, sizeof digest) != 0) { GKeyFile *keyfiles[2]; GTree *tree; tree = g_tree_new_full ((GCompareDataFunc) strcmp, NULL, g_free, g_free); keyfiles[0] = kfsb->keyfile; keyfiles[1] = g_key_file_new (); if (length > 0) g_key_file_load_from_data (keyfiles[1], contents, length, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, NULL); keyfile_to_tree (kfsb, tree, keyfiles[0], FALSE); keyfile_to_tree (kfsb, tree, keyfiles[1], TRUE); g_key_file_free (keyfiles[0]); kfsb->keyfile = keyfiles[1]; if (g_tree_nnodes (tree) > 0) g_settings_backend_changed_tree (&kfsb->parent_instance, tree, NULL); g_tree_unref (tree); memcpy (kfsb->digest, digest, sizeof digest); } g_free (contents); }
void destroy_host(host *this_host) { struct servicesmember *this_servicesmember, *next_servicesmember; struct contactgroupsmember *this_contactgroupsmember, *next_contactgroupsmember; struct contactsmember *this_contactsmember, *next_contactsmember; struct customvariablesmember *this_customvariablesmember, *next_customvariablesmember; struct objectlist *slavelist; if (!this_host) return; /* free memory for service links */ this_servicesmember = this_host->services; while (this_servicesmember != NULL) { next_servicesmember = this_servicesmember->next; nm_free(this_servicesmember); this_servicesmember = next_servicesmember; } /* free memory for contact groups */ this_contactgroupsmember = this_host->contact_groups; while (this_contactgroupsmember != NULL) { next_contactgroupsmember = this_contactgroupsmember->next; nm_free(this_contactgroupsmember); this_contactgroupsmember = next_contactgroupsmember; } /* free memory for contacts */ this_contactsmember = this_host->contacts; while (this_contactsmember != NULL) { next_contactsmember = this_contactsmember->next; nm_free(this_contactsmember); this_contactsmember = next_contactsmember; } /* free memory for custom variables */ this_customvariablesmember = this_host->custom_variables; while (this_customvariablesmember != NULL) { next_customvariablesmember = this_customvariablesmember->next; nm_free(this_customvariablesmember->variable_name); nm_free(this_customvariablesmember->variable_value); nm_free(this_customvariablesmember); this_customvariablesmember = next_customvariablesmember; } for (slavelist = this_host->notify_deps; slavelist; slavelist = slavelist->next) destroy_hostdependency(slavelist->object_ptr); for (slavelist = this_host->exec_deps; slavelist; slavelist = slavelist->next) destroy_hostdependency(slavelist->object_ptr); for (slavelist = this_host->escalation_list; slavelist; slavelist = slavelist->next) destroy_hostescalation(slavelist->object_ptr); while (this_host->hostgroups_ptr) remove_host_from_hostgroup(this_host->hostgroups_ptr->object_ptr, this_host); if (this_host->child_hosts) { struct host *curhost = NULL; do { curhost = NULL; g_tree_foreach(this_host->child_hosts, my_g_tree_visit_pick_one, &curhost); if(curhost) { remove_parent_from_host(curhost, this_host); } } while(curhost != NULL); g_tree_unref(this_host->child_hosts); this_host->child_hosts = NULL; } if (this_host->parent_hosts) { struct host *curhost = NULL; do { curhost = NULL; g_tree_foreach(this_host->parent_hosts, my_g_tree_visit_pick_one, &curhost); if(curhost) { remove_parent_from_host(this_host, curhost); } } while(curhost != NULL); g_tree_unref(this_host->parent_hosts); this_host->parent_hosts = NULL; } if (this_host->display_name != this_host->name) nm_free(this_host->display_name); if (this_host->alias != this_host->name) nm_free(this_host->alias); if (this_host->address != this_host->name) nm_free(this_host->address); nm_free(this_host->name); nm_free(this_host->plugin_output); nm_free(this_host->long_plugin_output); nm_free(this_host->perf_data); free_objectlist(&this_host->hostgroups_ptr); free_objectlist(&this_host->notify_deps); free_objectlist(&this_host->exec_deps); free_objectlist(&this_host->escalation_list); nm_free(this_host->check_command); nm_free(this_host->event_handler); nm_free(this_host->notes); nm_free(this_host->notes_url); nm_free(this_host->action_url); nm_free(this_host->icon_image); nm_free(this_host->icon_image_alt); nm_free(this_host->vrml_image); nm_free(this_host->statusmap_image); nm_free(this_host); }