void ep_delete (DDS_DomainParticipant part, DDS_BuiltinTopicKey_t *key) { Topic *tp; Endpoint *ep, *xep, *prev; ep = ep_lookup (key); if (!ep) { printf ("Already deleted?\r\n"); return; } printf ("* Delete %s (%s/%s)\r\n", (ep->writer) ? "writer" : "reader", ep->topic->topic_name, ep->topic->type_name); if (ep->writer) xep = ep->topic->writers; else xep = ep->topic->readers; /* Remove from topic endpoints list. */ for (prev = NULL; xep; prev = xep, xep = xep->link) if (xep == ep) { /* Found it! */ tp = ep->topic; if (!prev) if (ep->writer) tp->writers = ep->link; else tp->readers = ep->link; else prev->next = ep->link; /* If last writer and active reader: stop. */ if (ep->writer && !tp->writers && tp->active) stop_reader (part, tp); /* If no more readers nor writers, free topic. */ if (!tp->readers && !tp->writers) { if (tp->ts) cleanup_reader (part, tp); free (tp->topic_name); free (tp->type_name); LIST_REMOVE (topics, *tp); free (tp); } break; } /* Free endpoint. */ LIST_REMOVE (endpoints, *ep); free (ep); }
static void do_read_file_cleanup(struct cleanup * base) { struct read_file_cleanup * pcleanup; remove_cleanup(base); pcleanup = container_of(base, struct read_file_cleanup, base); struct png_reader * reader = &pcleanup->reader; cleanup_reader(reader); if (reader->io_ptr != NULL) { FILE * fp = reader->io_ptr; fclose(fp); reader->io_ptr = NULL; } GC_TRIVAL_FREE(pcleanup); }