void conscience_srv_destroy(struct conscience_srv_s *service) { if (!service) return; /*free the tags */ if (service->tags) { while (service->tags->len > 0) { struct service_tag_s *tag = g_ptr_array_index(service->tags,0); service_tag_destroy(tag); g_ptr_array_remove_index_fast(service->tags, 0); } g_ptr_array_free(service->tags, TRUE); } if (service->app_data_type==SAD_PTR) { if (service->app_data.pointer.value && service->app_data.pointer.cleaner) service->app_data.pointer.cleaner(service->app_data.pointer.value); } /*remove from the ring */ service_ring_remove(service); /*cleans the structure */ memset(service, 0x00, sizeof(struct conscience_srv_s)); g_free(service); }
void service_info_remove_tag(GPtrArray * a, const gchar * name) { if (!a || !name || a->len <= 0) return; const guint max = a->len; for (guint i = 0; i < max; i++) { struct service_tag_s *pSrv = g_ptr_array_index(a, i); if (!pSrv) continue; if (!strcmp(pSrv->name, name)) { service_tag_destroy(pSrv); g_ptr_array_remove_index_fast(a, i); return; } } }
void service_info_clean(struct service_info_s *si) { if (!si) return; if (si->tags) { GPtrArray *pa = si->tags; while (pa->len > 0) { struct service_tag_s *tag; tag = g_ptr_array_index(pa, 0); g_ptr_array_remove_index_fast(pa, 0); service_tag_destroy(tag); } g_ptr_array_free(pa, TRUE); } g_free(si); }
void service_info_remove_tag(GPtrArray * a, const gchar * name) { gsize len; register guint i, max; if (!a || !name || a->len <= 0) return; len = MIN(strlen(name) + 1, LIMIT_LENGTH_TAGNAME); for (i = 0, max = a->len; i < max; i++) { struct service_tag_s *pSrv; pSrv = g_ptr_array_index(a, i); if (!pSrv) continue; if (!g_ascii_strncasecmp(pSrv->name, name, len)) { service_tag_destroy(pSrv); g_ptr_array_remove_index_fast(a, i); return; } } }