Ejemplo n.º 1
0
void unsorted_mode() {
	queue_t *q = queue_create();
	
	char *t1 = malloc(1);
	char *t2 = malloc(2);
	char *t3 = malloc(4);
	char *t4 = malloc(8);
	
	test *s1 = malloc(sizeof(test));
	s1->test = t1; 
	test *s2 = malloc(sizeof(test));
	s2->test = t2; 
	test *s3 = malloc(sizeof(test));
	s3->test = t3; 
	test *s4 = malloc(sizeof(test));
	s4->test = t4; 
	
	queue_put(q, s1);
	queue_put(q, s2);
	queue_put(q, s3);
	queue_put(q, s4);
	
	test *t;
	queue_get(q, (void **)&t);
	free_test(t);
	queue_get(q, (void **)&t);
	free_test(t);
	
	queue_destroy_complete(q, (void *)free_test);
}
Ejemplo n.º 2
0
void free_tree(commandlist_t *cl)
{
    commandlist_t *cl2;

    while (cl != NULL) {
	cl2 = cl->next;
	switch (cl->type) {
	case IF:
	    free_test(cl->u.i.t);
	    free_tree(cl->u.i.do_then);
	    free_tree(cl->u.i.do_else);
	    break;

	case FILEINTO:
	case REDIRECT:
	case REJCT:
	    if (cl->u.str) free(cl->u.str);
	    break;

	case VACATION:
	    if (cl->u.v.subject) free(cl->u.v.subject);
	    if (cl->u.v.addresses) free_sl(cl->u.v.addresses);
	    if (cl->u.v.message) free(cl->u.v.message);
	    break;
	    
	case SETFLAG:
	case ADDFLAG:
	case REMOVEFLAG:
	    free_sl(cl->u.sl);
	    break;

	case KEEP:
	case STOP:
	case DISCARD:
	    break;

	case NOTIFY:
	    if (cl->u.n.method) free(cl->u.n.method);
	    if (cl->u.n.id) free(cl->u.n.id);
	    if (cl->u.n.options) free_sl(cl->u.n.options);
	    if (cl->u.n.message) free(cl->u.n.message);
	    break;

	case DENOTIFY:
	    if (cl->u.d.pattern) {
#ifdef ENABLE_REGEX
		if (cl->u.d.comptag == REGEX) {
		    regfree((regex_t *) cl->u.d.pattern);
		}
#endif
		free(cl->u.d.pattern);
	    }
	    break;
	}

	free(cl);
	cl = cl2;
    }
}
Ejemplo n.º 3
0
void free_test(test_t *t)
{
    if (t == NULL) return;

    switch (t->type) {
    case ANYOF:
    case ALLOF:
        free_tl(t->u.tl);
        break;

    case EXISTS:
        strarray_free(t->u.sl);
        break;

    case SIZE:
    case SFALSE:
    case STRUE:
        break;

    case HASFLAG:
    case HEADER:
        free(t->u.h.comparator);
        strarray_free(t->u.h.sl);
        strarray_free(t->u.h.pl);
        break;

    case ADDRESS:
    case ENVELOPE:
        free(t->u.ae.comparator);
        strarray_free(t->u.ae.sl);
        strarray_free(t->u.ae.pl);
        break;

    case BODY:
        free(t->u.b.comparator);
        strarray_free(t->u.b.content_types);
        strarray_free(t->u.b.pl);
        break;

    case NOT:
        free_test(t->u.t);
        break;

    case DATE:
        free(t->u.dt.header_name);
        /* fall-through */
    case CURRENTDATE:
        free(t->u.dt.comparator);
        free(t->u.dt.zone);
        strarray_free(t->u.dt.kl);
        break;
    }

    free(t);
}
Ejemplo n.º 4
0
static void free_tl(testlist_t *tl)
{
    testlist_t *tl2;

    while (tl) {
	tl2 = tl->next;

	if (tl->t) free_test(tl->t);

	free(tl);
	tl = tl2;
    }
}
Ejemplo n.º 5
0
int main()
{
	init(50);
  
	int *p = malloc_test(array, 5);
	malloc_test(array, 10);
	free_test(array, p, 5);
	malloc_test(array, 4);
	
	
	gui_show_array(array);
  
	return 0;
}
Ejemplo n.º 6
0
void free_test(test_t *t)
{
    if (t == NULL) return;

    switch (t->type) {
    case ANYOF:
    case ALLOF:
	free_tl(t->u.tl);
	break;

    case EXISTS:
	strarray_free(t->u.sl);
	break;

    case SIZE:
    case SFALSE:
    case STRUE:
	break;

    case HEADER:
	strarray_free(t->u.h.sl);
	strarray_free(t->u.h.pl);
	
	break;

    case ADDRESS:
    case ENVELOPE:
	free(t->u.ae.comparator);
	strarray_free(t->u.ae.sl);
	strarray_free(t->u.ae.pl);
	break;

    case BODY:
	strarray_free(t->u.b.content_types);
	strarray_free(t->u.b.pl);
	break;

    case NOT:
	free_test(t->u.t);
	break;
    }

    free(t);
}
Ejemplo n.º 7
0
void free_test(test_t *t)
{
    if (t == NULL) return;

    switch (t->type) {
    case ANYOF:
    case ALLOF:
	free_tl(t->u.tl);
	break;

    case EXISTS:
	free_sl(t->u.sl);
	break;

    case SIZE:
    case SFALSE:
    case STRUE:
	break;

    case HEADER:
	free_sl(t->u.h.sl);
	free_pl(t->u.h.pl, t->u.h.comptag);
	break;

    case ADDRESS:
	free_sl(t->u.ae.sl);
	free_pl(t->u.ae.pl, t->u.ae.comptag);
	break;

    case NOT:
	free_test(t->u.t);
	break;
    }

    free(t);
}