/* * Mole destructor */ Mole::~Mole() { if (this->is_conversing) stopConversion(); if (this->is_connected) disconnect(); int ret = me_destroy(); if (ret < 0) qDebug("[Error] Can't me_destroy (ret = 0x%.2x)", -ret); else qDebug("[Success] destroyed successfull"); }
int main(int argc, char *argv[]) { MEntry *mep, *meq; MList *ml; char *p; int c; int varg = 0; if (argc > 2) { usage(); return -1; } if (argc == 2) { p = argv[1]; if (*p++ != '-') { usage(); return -1; } while ((c = *p++) != '\0') { if (c =='v' || c == 'V') varg++; else { fprintf(stderr, "Illegal flag: %c\n", c); usage(); return -1; } } } ml_verbose = varg; ml = ml_create(); while ((mep = me_get(stdin)) != NULL) { meq = ml_lookup(ml, mep); if (meq == NULL) (void) ml_add(&ml, mep); else { printf("Potential duplicate\n"); printf("===================\n"); me_print(mep, stdout); printf("==========\n"); me_print(meq, stdout); printf("\n"); me_destroy(mep); } } ml_destroy(ml); return 0; }
/* ml_destroy - destroy the mailing list */ void ml_destroy(MList *ml) { MListNode *cur, *freed; unsigned long i; if (ml_verbose) fprintf(stderr, "mlist: ml_destroy() entered\n"); for (i = 0; i < ml->size; ++i) { // iterate to all buckets in hash table for (cur = ml->hash_table[i].first; cur != NULL;) { // iterate to all nodes in a bucket freed = cur; // remember the node to be destroy cur = cur->next; // prepare to traverse to the next node me_destroy(freed->entry); // destroy mail entry in the node free(freed); // destroy the node } } free((void *) ml->hash_table); free((void *) ml); }