Пример #1
0
// クロスフェードモザイク
static void ec6_cb(surface_t *src, surface_t *dst) {
	int curstep, maxstep = 32;
	surface_t *st, *dt;
        static int slices[32]={4,8,12,16,20,28,36,40,44,48,56,64,72,80,88,96,
                               88,80,72,64,56,48,44,40,36,28,24,20,16,12,8,4};
	

	curstep = maxstep * (ecp.curtime - ecp.sttime)/ (ecp.edtime - ecp.sttime);
	if (ecp.oldstep == curstep) {
		usleep(0);
		return;
	}
	st = sf_dup(src);
	dt = sf_dup(dst);

	image_Mosaic(st, 0, 0, st->width, st->height, 0, 0, slices[curstep]);
	image_Mosaic(dt, 0, 0, dt->width, dt->height, 0, 0, slices[curstep]);
	
	gre_Blend(sf0, 0, 0, st, 0, 0, dt, 0, 0, st->width, st->height, curstep*8);
	ags_updateFull();
	
	sf_free(st);
	sf_free(dt);
	
	ecp.oldstep = curstep;
}
Пример #2
0
/*
  効果つき画面更新
  @param type: 効果の種類
  @param time: 実行時間
  @param cancel: キー抜け(0:なし, 1:あり)
*/
int sp_eupdate(int type, int time, int cancel) {
	surface_t *sfsrc, *sfdst;
	int key;

	if (sact.waitskiplv > 1) {
		sp_update_all(TRUE);
		return OK;
	}
	
	// 現在の sf0 をセーブ
	sfsrc = sf_dup(sf0);
	
	sp_update_all(FALSE);
	
	sfdst = sf_dup(sf0);
	
	sf_copyall(sf0, sfsrc); // 全部の効果タイプにこの処理は要らないんだけど
	// 5つを越えたら別の方法を考えよう
	if (type == 10) {
		ec10_prepare(sfsrc, sfdst);
	}
	if (type == 11) {
		ec11_prepare(sfsrc, sfdst);
	}
	if (type == 19) {
		ec19_prepare(sfsrc, sfdst);
	}
	
	ecp.sttime = ecp.curtime = get_high_counter(SYSTEMCOUNTER_MSEC);
	ecp.edtime = ecp.curtime + time*10;
	ecp.oldstep = 0;
	
	while ((ecp.curtime = get_high_counter(SYSTEMCOUNTER_MSEC)) < ecp.edtime) {
		int rest;
		
		(*cb[type-1])(sfsrc, sfdst);
		rest = 15 - (get_high_counter(SYSTEMCOUNTER_MSEC) - ecp.curtime);
		key = sys_keywait(rest, cancel);
		
		if (cancel && key) break;
	}
	
	sf_copyall(sf0, sfdst);
	ags_updateFull();
	sf_free(sfsrc);
	sf_free(sfdst);

	if (type == 10) {
		ec10_drain(sfsrc, sfdst);
	}
	if (type == 11) {
		ec11_drain(sfsrc, sfdst);
	}
	if (type == 19) {
		ec19_drain(sfsrc, sfdst);
	}
	
	return OK;
}
Пример #3
0
void sf_var_free(sf_vartable_t *v)
{
    #if 0
    sf_free(v->name);
    sf_free(v->value);
    sf_free(v);
    #endif
}
Пример #4
0
//
// check_consistency -- test that the ON-set, OFF-set and DC-set form
// a partition of the boolean space.
//
bool
check_consistency(PLA_t *PLA)
{
    bool verify_error = FALSE;
    set_family_t *T;

    T = cv_intersect(PLA->F, PLA->D);
    if (T->count == 0)
        printf("ON-SET and DC-SET are disjoint\n");
    else {
        printf("Some minterm(s) belong to both the ON-SET and DC-SET !\n");
        if (verbose_debug)
            cprint(T);
        verify_error = TRUE;
    }
    fflush(stdout);
    sf_free(T);

    T = cv_intersect(PLA->F, PLA->R);
    if (T->count == 0)
        printf("ON-SET and OFF-SET are disjoint\n");
    else {
        printf("Some minterm(s) belong to both the ON-SET and OFF-SET !\n");
        if (verbose_debug)
            cprint(T);
        verify_error = TRUE;
    }
    fflush(stdout);
    sf_free(T);

    T = cv_intersect(PLA->D, PLA->R);
    if (T->count == 0)
        printf("DC-SET and OFF-SET are disjoint\n");
    else {
        printf("Some minterm(s) belong to both the OFF-SET and DC-SET !\n");
        if (verbose_debug)
            cprint(T);
        verify_error = TRUE;
    }
    fflush(stdout);
    sf_free(T);

    if (tautology(cube3list(PLA->F, PLA->D, PLA->R)))
        printf("Union of ON-SET, OFF-SET and DC-SET is the universe\n");
    else {
        T = complement(cube3list(PLA->F, PLA->D, PLA->R));
        printf("There are minterms left unspecified !\n");
        if (verbose_debug)
            cprint(T);
        verify_error = TRUE;
        sf_free(T);
    }
    fflush(stdout);
    return verify_error;
}
Пример #5
0
static void ec10_drain(surface_t *src, surface_t *dst) {
	int i;
	
	for (i = 0; i < 6; i++) {
		sf_free(ec10_sf[i]);
	}
}
Пример #6
0
pset_family irred_gasp(pset_family F, pset_family D, pset_family G)
{
if (G->count != 0)
F = irredundant(sf_append(F, G), D);
else
sf_free(G);
return F;
}
Пример #7
0
find_equiv_outputs(pPLA PLA)
{
int i, j, ipart, jpart, some_equiv;
pset_family *R, *F;
some_equiv = 0;
makeup_labels(PLA);
F = ((pset_family *) malloc(sizeof(pset_family) * ( cube.part_size[cube.output])));
R = ((pset_family *) malloc(sizeof(pset_family) * ( cube.part_size[cube.output])));
for(i = 0; i < cube.part_size[cube.output]; i++) {
ipart = cube.first_part[cube.output] + i;
R[i] = cof_output(PLA->R, ipart);
F[i] = complement(cube1list(R[i]));
}
for(i = 0; i < cube.part_size[cube.output]-1; i++) {
for(j = i+1; j < cube.part_size[cube.output]; j++) {
ipart = cube.first_part[cube.output] + i;
jpart = cube.first_part[cube.output] + j;
if (check_equiv(F[i], F[j])) {
printf("# Outputs %d and %d (%s and %s) are equivalent\n",
i, j, PLA->label[ipart], PLA->label[jpart]);
some_equiv = 1;
} else if (check_equiv(F[i], R[j])) {
printf("# Outputs %d and NOT %d (%s and %s) are equivalent\n",
i, j, PLA->label[ipart], PLA->label[jpart]);
some_equiv = 1;
} else if (check_equiv(R[i], F[j])) {
printf("# Outputs NOT %d and %d (%s and %s) are equivalent\n",
i, j, PLA->label[ipart], PLA->label[jpart]);
some_equiv = 1;
} else if (check_equiv(R[i], R[j])) {
printf("# Outputs NOT %d and NOT %d (%s and %s) are equivalent\n",
i, j, PLA->label[ipart], PLA->label[jpart]);
some_equiv = 1;
}
}
}
if (! some_equiv) {
printf("# No outputs are equivalent\n");
}
for(i = 0; i < cube.part_size[cube.output]; i++) {
sf_free(F[i]);
sf_free(R[i]);
}
((F) ? (free((char *) (F)), (F) = 0) : 0);
((R) ? (free((char *) (R)), (R) = 0) : 0);
}
Пример #8
0
pset_family last_gasp(pset_family F, pset_family D, pset_family R, cost_t *cost)
{
pset_family G, G1;
{long t=util_cpu_time();G = reduce_gasp(F, D);totals(t, 9, G,&( *cost));};
{long t=util_cpu_time();G1 = expand_gasp(G, D, R, F);totals(t, 7, G1,&( *cost));};
sf_free(G);
{long t=util_cpu_time();F = irred_gasp(F, D, G1);totals(t, 8, F,&( *cost));};
return F;
}
Пример #9
0
pset_family super_gasp(pset_family F, pset_family D, pset_family R, cost_t *cost)
{
pset_family G, G1;
{long t=util_cpu_time();G = reduce_gasp(F, D);totals(t, 9, G,&( *cost));};
{long t=util_cpu_time();G1 = all_primes(G, R);totals(t, 7, G1,&( *cost));};
sf_free(G);
{long t=util_cpu_time();G = sf_dupl(sf_append(F, G1));if(trace)print_trace( G, "NEWPRIMES",util_cpu_time()-t);};
{long t=util_cpu_time();F = irredundant(G, D);totals(t, 5, F,&( *cost));};
return F;
}
Пример #10
0
void nt_gr_screencg(int no, int x, int y) {
	surface_t *sf;
	
	ags_sync();
	
	sf = sf_loadcg_no(no -1);
	
	gre_BlendScreen(sf0, x, y, sf0, x, y, sf, 0, 0, sf->width, sf->height);
	
	ags_updateArea(x, y, sf->width, sf->height);
	
	sf_free(sf);
}
Пример #11
0
void sp_free(sprite_t *sp) {
	if (sp == NULL) return;
	
	if (sp->cg1) scg_free_cgobj(sp->cg1);
	if (sp->cg2) scg_free_cgobj(sp->cg2);
	if (sp->cg3) scg_free_cgobj(sp->cg3);

	if (sp->type == SPRITE_MSG) {
		sf_free(sp->u.msg.canvas);
	}
	
	g_free(sp);
}
Пример #12
0
void expand1_gasp(pset_family F, pset_family D, pset_family R, pset_family Foriginal, int c1index, pset_family *G)
{
register int c2index;
register pset p, last, c2under;
pset RAISE, FREESET, temp, *FD, c2essential;
pset_family F1;
if (debug & 0x0008) {
printf("\nEXPAND1_GASP:    \t%s\n", pc1(((F)->data + (F)->wsize * ( c1index))));
}
RAISE = set_clear(((unsigned int *) malloc(sizeof(unsigned int) * ( ((cube.size) <= 32 ? 2 : (((((cube.size)-1) >> 5) + 1) + 1))))), cube.size);
FREESET = set_clear(((unsigned int *) malloc(sizeof(unsigned int) * ( ((cube.size) <= 32 ? 2 : (((((cube.size)-1) >> 5) + 1) + 1))))), cube.size);
temp = set_clear(((unsigned int *) malloc(sizeof(unsigned int) * ( ((cube.size) <= 32 ? 2 : (((((cube.size)-1) >> 5) + 1) + 1))))), cube.size);
R->active_count = R->count;
for( p=R->data, last= p+R->count*R->wsize; p< last; p+=R->wsize) {
(p[0] |= ( 0x2000));
}
F->active_count = F->count;
for( c2under=F->data, c2index=0; c2index<F->count; c2under+=F->wsize, c2index++) {
if (c1index == c2index || (c2under[0] & ( 0x8000))) {
F->active_count--;
(c2under[0] &= ~ ( 0x2000));
} else {
(c2under[0] |= ( 0x2000));
}
}
(void) set_copy(RAISE, ((F)->data + (F)->wsize * ( c1index)));
(void) set_diff(FREESET, cube.fullset, RAISE);
essen_parts(R, F, RAISE, FREESET);
essen_raising(R, RAISE, FREESET);
for( c2under=F->data, c2index=0; c2index<F->count; c2under+=F->wsize, c2index++) {
if ((c2under[0] & ( 0x2000))) {
if (setp_implies(c2under, RAISE) ||
feasibly_covered(R, c2under, RAISE, temp)) {
F1 = sf_save(Foriginal);
(void) set_copy(((F1)->data + (F1)->wsize * ( c1index)), ((F)->data + (F)->wsize * ( c1index)));
FD = cube2list(F1, D);
c2essential = reduce_cube(FD, ((F1)->data + (F1)->wsize * ( c2index)));
((FD[0]) ? (free((char *) (FD[0])), (FD[0]) = 0) : 0); ((FD) ? (free((char *) (FD)), (FD) = 0) : 0);;
sf_free(F1);
if (feasibly_covered(R, c2essential, RAISE, temp)) {
(void) set_or(temp, RAISE, c2essential);
(temp[0] &= ~ ( 0x8000));	*G = sf_addset(*G, temp);
}
((c2essential) ? (free((char *) (c2essential)), (c2essential) = 0) : 0);
}
}
}
((RAISE) ? (free((char *) (RAISE)), (RAISE) = 0) : 0);
((FREESET) ? (free((char *) (FREESET)), (FREESET) = 0) : 0);
((temp) ? (free((char *) (temp)), (temp) = 0) : 0);
}
Пример #13
0
void free_args(arguments_t *a) {

  if(a == NULL) {
    return;
  }

  if(a->log_fd != -1) {
    close(a->log_fd);
  }

  if(strcmp(a->sdp_file, "") != 0) {
    sf_free(a->src_filt);
    free(a->src_filt);
    sdp_message_free(a->sdp);
  }
}
Пример #14
0
/**Function*************************************************************

  Synopsis    [Minimizes SOP representation of one node.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Abc_NodeEspresso( Abc_Obj_t * pNode )
{
    extern void define_cube_size( int n );
    pset_family Cover;
    int fCompl;

    assert( Abc_ObjIsNode(pNode) );
    // define the cube for this node
    define_cube_size( Abc_ObjFaninNum(pNode) );
    // create the Espresso cover
    fCompl = Abc_SopIsComplement( pNode->pData );
    Cover = Abc_SopToEspresso( pNode->pData );
    // perform minimization
    Cover = Abc_EspressoMinimize( Cover, NULL ); // deletes also cover
    // convert back onto the node's SOP representation
    pNode->pData = Abc_SopFromEspresso( pNode->pNtk->pManFunc, Cover );
    if ( fCompl ) Abc_SopComplement( pNode->pData );
    sf_free(Cover);
}
Пример #15
0
int32_t tcp_buffer_new(struct tcp_buffer_class **tcpbuf, size_t size)
{
    struct tcp_buffer_class *cbuf;

    cbuf = sf_malloc(sizeof(*cbuf));
    if (!cbuf)
        return -1;

    memset(cbuf, 0, sizeof(*cbuf));

    ts_cbuffer_new(&cbuf->cbuffer, size);
    if (!cbuf->cbuffer) {
        sf_free(cbuf);
        return -1;
    }

    cbuf->size = size;
    *tcpbuf = cbuf;
    return 0;
}
Пример #16
0
/**
 * CG オブジェクトの開放
 */
int scg_free_cgobj(cginfo_t *cg) {
	if (cg == NULL) return NG;
	
	(cg->refcnt)--;
	// 他でまだ参照していれば開放しない
	if (cg->refcnt > 0) {
		return NG;
	}
	
	// CG本体の開放
	if (cg->sf) {
		sf_free(cg->sf);
	}
	
	// 削除するオブジェクトを参照しているオブジェクトリストも削除
	if (cg == sact.cg[cg->no]) {
		sact.cg[cg->no] = NULL;
	}
	
	g_free(cg);
	
	return OK;
}
Пример #17
0
void tcp_buffer_delete(struct tcp_buffer_class *tcpbuf)
{
    ts_cbuffer_delete(tcpbuf->cbuffer);
    sf_free(tcpbuf);
}
Пример #18
0
int main()
{
	char* buffer = sf_malloc(1024);
	puts("Hello.");
	sf_free(buffer);

	sf_list_ptr my_list = sf_list_alloc();

	// Test single node list

	sf_list_node_ptr node1 = sf_list_node_alloc(NULL);
	sf_list_push(my_list, node1);
	assert(my_list->first == node1);
	assert(my_list->last == node1);
	assert(node1->next == NULL);
	assert(node1->prev == NULL);

	sf_list_node_ptr popped_node = sf_list_pop(my_list);
	assert(popped_node == node1);
	assert(node1->next == NULL);
	assert(node1->prev == NULL);
	assert(my_list->first == NULL);
	assert(my_list->last == NULL);

	// Test two node list: push 2 nodes

	sf_list_node_ptr node2 = sf_list_node_alloc(NULL);
	sf_list_push(my_list, node1);
	sf_list_push(my_list, node2);
	assert(my_list->first == node1);
	assert(my_list->last == node2);
	assert(node1->prev == NULL);
	assert(node1->next == node2);
	assert(node2->prev == node1);
	assert(node2->next == NULL);

	// Pop node 2

	popped_node = sf_list_pop(my_list);
	assert(popped_node == node2);
	assert(node2->next == NULL);
	assert(node2->prev == NULL);
	assert(node1->next == NULL);
	assert(node1->prev == NULL);
	assert(my_list->first == node1);
	assert(my_list->last == node1);

	// Pop node 1

	popped_node = sf_list_pop(my_list);
	assert(popped_node == node1);
	assert(node1->next == NULL);
	assert(node1->prev == NULL);
	assert(my_list->first == NULL);
	assert(my_list->last == NULL);

	// Test three node list: push 3 nodes

	sf_list_node_ptr node3 = sf_list_node_alloc(NULL);
	sf_list_push(my_list, node1);
	sf_list_push(my_list, node2);
	sf_list_push(my_list, node3);
	assert(my_list->first == node1);
	assert(my_list->last == node3);
	assert(node1->prev == NULL);
	assert(node1->next == node2);
	assert(node2->prev == node1);
	assert(node2->next == node3);
	assert(node3->prev == node2);
	assert(node3->next == NULL);

	// Pop node 3

	popped_node = sf_list_pop(my_list);
	assert(popped_node == node3);
	assert(node3->next == NULL);
	assert(node3->prev == NULL);
	assert(node2->next == NULL);
	assert(node2->prev == node1);
	assert(node1->next == node2);
	assert(node1->prev == NULL);
	assert(my_list->first == node1);
	assert(my_list->last == node2);

	// Pop node 2

	popped_node = sf_list_pop(my_list);
	assert(popped_node == node2);
	assert(node2->next == NULL);
	assert(node2->prev == NULL);
	assert(node1->next == NULL);
	assert(node1->prev == NULL);
	assert(my_list->first == node1);
	assert(my_list->last == node1);

	// Pop node 1

	popped_node = sf_list_pop(my_list);
	assert(popped_node == node1);
	assert(node1->next == NULL);
	assert(node1->prev == NULL);
	assert(my_list->first == NULL);
	assert(my_list->last == NULL);

	// Test insert_after

	sf_list_insert_after(my_list, node1, NULL);
	assert(my_list->first == node1);
	assert(my_list->last == node1);
	assert(node1->next == NULL);
	assert(node1->prev == NULL);

	sf_list_insert_after(my_list, node2, node1);
	assert(my_list->first == node1);
	assert(my_list->last == node2);
	assert(node1->prev == NULL);
	assert(node1->next == node2);
	assert(node2->prev == node1);
	assert(node2->next == NULL);

	sf_list_insert_after(my_list, node3, node2);
	assert(my_list->first == node1);
	assert(my_list->last == node3);
	assert(node1->prev == NULL);
	assert(node1->next == node2);
	assert(node2->prev == node1);
	assert(node2->next == node3);
	assert(node3->prev == node2);
	assert(node3->next == NULL);

	sf_list_pop(my_list);
	sf_list_insert_after(my_list, node3, node1); // makes: 1, 3, 2
	assert(my_list->first == node1);
	assert(my_list->last == node2);
	assert(node1->prev == NULL);
	assert(node1->next == node3);
	assert(node3->prev == node1);
	assert(node3->next == node2);
	assert(node2->prev == node3);
	assert(node2->next == NULL);

	sf_list_pop(my_list);
	sf_list_pop(my_list);
	sf_list_pop(my_list);

	// Test remove

	sf_list_push(my_list, node1);
	sf_list_remove(my_list, node1);
	assert(my_list->first == NULL);
	assert(my_list->last == NULL);

	sf_list_push(my_list, node1);
	sf_list_push(my_list, node2);
	sf_list_remove(my_list, node2);
	assert(my_list->first == node1);
	assert(my_list->last == node1);
	assert(node1->next == NULL);
	assert(node1->prev == NULL);
	sf_list_pop(my_list);

	sf_list_push(my_list, node1);
	sf_list_push(my_list, node2);
	sf_list_remove(my_list, node1);
	assert(my_list->first == node2);
	assert(my_list->last == node2);
	assert(node2->next == NULL);
	assert(node2->prev == NULL);
	sf_list_pop(my_list);

	sf_list_push(my_list, node1);
	sf_list_push(my_list, node2);
	sf_list_push(my_list, node3);
	sf_list_remove(my_list, node1);
	assert(my_list->first == node2);
	assert(my_list->last == node3);
	assert(node2->next == node3);
	assert(node2->prev == NULL);
	assert(node3->next == NULL);
	assert(node3->prev == node2);
	sf_list_pop(my_list);
	sf_list_pop(my_list);

	sf_list_push(my_list, node1);
	sf_list_push(my_list, node2);
	sf_list_push(my_list, node3);
	sf_list_remove(my_list, node2);
	assert(my_list->first == node1);
	assert(my_list->last == node3);
	assert(node1->next == node3);
	assert(node1->prev == NULL);
	assert(node3->next == NULL);
	assert(node3->prev == node1);
	sf_list_pop(my_list);
	sf_list_pop(my_list);

	sf_list_push(my_list, node1);
	sf_list_push(my_list, node2);
	sf_list_push(my_list, node3);
	sf_list_remove(my_list, node3);
	assert(my_list->first == node1);
	assert(my_list->last == node2);
	assert(node1->next == node2);
	assert(node1->prev == NULL);
	assert(node2->next == NULL);
	assert(node2->prev == node1);
	sf_list_pop(my_list);
	sf_list_pop(my_list);

	// Clean up

	sf_list_node_free(node1);
	sf_list_node_free(node2);
	sf_list_node_free(node3);
	sf_list_free(my_list);

	sf_malloc_check();

	return 0;
}
Пример #19
0
static bool
compl_special_cases(set **T, set_family_t **Tbar)
{
    set **T1, *p, *ceil, *cof=T[0];
    set_family_t *A, *ceil_compl;

    // Check for no cubes in the cover
    if (T[2] == NULL) {
        *Tbar = sf_addset(sf_new(1, CUBE.size), CUBE.fullset);
        free_cubelist(T);
        return TRUE;
    }

    // Check for only a single cube in the cover
    if (T[3] == NULL) {
        *Tbar = compl_cube(set_or(cof, cof, T[2]));
        free_cubelist(T);
        return TRUE;
    }

    // Check for a row of all 1's (implies complement is null)
    for (T1 = T+2; (p = *T1++) != NULL; ) {
        if (full_row(p, cof)) {
            *Tbar = sf_new(0, CUBE.size);
            free_cubelist(T);
            return TRUE;
        }
    }

    // Check for a column of all 0's which can be factored out
    ceil = set_save(cof);
    for (T1 = T+2; (p = *T1++) != NULL; ) {
        set_or(ceil, ceil, p);
    }
    if (! setp_equal(ceil, CUBE.fullset)) {
        ceil_compl = compl_cube(ceil);
        set_or(cof, cof, set_diff(ceil, CUBE.fullset, ceil));
        set_free(ceil);
        *Tbar = sf_append(complement(T), ceil_compl);
        return TRUE;
    }
    set_free(ceil);

    // Collect column counts, determine unate variables, etc.
    massive_count(T);

    // If single active variable not factored out above, then tautology!
    if (CDATA.vars_active == 1) {
        *Tbar = sf_new(0, CUBE.size);
        free_cubelist(T);
        return TRUE;

    // Check for unate cover
    } else if (CDATA.vars_unate == CDATA.vars_active) {
        A = map_cover_to_unate(T);
        free_cubelist(T);
        A = unate_compl(A);
        *Tbar = map_unate_to_cover(A);
        sf_free(A);
        return TRUE;

    // Not much we can do about it
    } else {
        return MAYBE;
    }
}
Пример #20
0
static bool compl_special_cases(pset *T, pset_family *Tbar)
  /* will be disposed if answer is determined */
  /* returned only if answer determined */
{
  register pcube *T1, p, ceil, cof=T[0];
  pcover A, ceil_compl;

  /* Check for no cubes in the cover */
  if (T[2] == NULL) {
    *Tbar = sf_addset(new_cover(1), cube.fullset);
    free_cubelist(T);
    return TRUE;
  }

  /* Check for only a single cube in the cover */
  if (T[3] == NULL) {
    *Tbar = compl_cube(set_or(cof, cof, T[2]));
    free_cubelist(T);
    return TRUE;
  }

  /* Check for a row of all 1's (implies complement is null) */
  for(T1 = T+2; (p = *T1++) != NULL; ) {
    if (full_row(p, cof)) {
      *Tbar = new_cover(0);
      free_cubelist(T);
      return TRUE;
    }
  }

  /* Check for a column of all 0's which can be factored out */
  ceil = set_save(cof);
  for(T1 = T+2; (p = *T1++) != NULL; ) {
    INLINEset_or(ceil, ceil, p);
  }
  if (! setp_equal(ceil, cube.fullset)) {
    ceil_compl = compl_cube(ceil);
    (void) set_or(cof, cof, set_diff(ceil, cube.fullset, ceil));
    set_free(ceil);
    *Tbar = sf_append(complement(T), ceil_compl);
    return TRUE;
  }
  set_free(ceil);

  /* Collect column counts, determine unate variables, etc. */
  massive_count(T);

  /* If single active variable not factored out above, then tautology ! */
  if (cdata.vars_active == 1) {
    *Tbar = new_cover(0);
    free_cubelist(T);
    return TRUE;

    /* Check for unate cover */
  } else if (cdata.vars_unate == cdata.vars_active) {
    A = map_cover_to_unate(T);
    free_cubelist(T);
    A = unate_compl(A);
    *Tbar = map_unate_to_cover(A);
    sf_free(A);
    return TRUE;

    /* Not much we can do about it */
  } else {
    return MAYBE;
  }
}
Пример #21
0
int main(int argc, char *argv[]) {
    // Initialize the custom allocator
    sf_mem_init(MAX_HEAP_SIZE);

    // Tell the user about the fields
    info("Initialized heap with %dmb of heap space.\n", MAX_HEAP_SIZE >> 20);
    //press_to_cont(); 

    // Print out title for first test
    printf("=== Test1: Allocation test ===\n");
    // Test #1: Allocate an integer
    int *value1 = sf_malloc(sizeof(int));
    null_check(value1, sizeof(int));
    payload_check(value1);
    // Print out the allocator block
    sf_varprint(value1);
    //press_to_cont();

    // Now assign a value
    printf("=== Test2: Assignment test ===\n");
    info("Attempting to assign value1 = %d\n", VALUE1_VALUE);
    // Assign the value
    *value1 = VALUE1_VALUE;
    // Now check its value
    check_prim_contents(value1, VALUE1_VALUE, "%d", "value1");
    //press_to_cont();

    printf("=== Test3: Allocate a second variable ===\n");
    info("Attempting to assign value2 = %ld\n", VALUE2_VALUE);
    long *value2 = sf_malloc(sizeof(long));
    null_check(value2, sizeof(long));
    payload_check(value2);
    sf_varprint(value2);
    // Assign a value
    *value2 = VALUE2_VALUE;
    // Check value
    check_prim_contents(value2, VALUE2_VALUE, "%ld", "value2");
    //press_to_cont();

    printf("=== Test4: does value1 still equal %d ===\n", VALUE1_VALUE);
    check_prim_contents(value1, VALUE1_VALUE, "%d", "value1");
    //press_to_cont();

    // Snapshot the freelist
    printf("=== Test5: Perform a snapshot ===\n");
    sf_snapshot(true);
    //press_to_cont();

    // Free a variable
    printf("=== Test6: Free a block and snapshot ===\n");
    info("Freeing value1...\n");
    sf_free(value1);
    sf_snapshot(true);
    //press_to_cont();

    // Allocate more memory
    printf("=== Test7: 8192 byte allocation ===\n");
    void *memory = sf_calloc(4096,1);
    sf_varprint(memory);
    perror("Testing calloc");
    sf_snapshot(true);
    memory = sf_malloc(8192);
    sf_varprint(memory);
    perror("Testing free");
    sf_free(memory);
    //press_to_cont();

    return EXIT_SUCCESS;
}