예제 #1
0
파일: memory.c 프로젝트: JackHolland/Tap
/*! A helper function for freeExpr and freeExprNR
    @param expr     the expression to free from memory
    @param next     whether to free the next expression as well as the given one
    @return         0
*/
static bool freeExpr_ (expression* expr, bool next) {
    if (expr != NULL) { // if the expression isn't null
        exprvals ev = expr->ev;
        switch (expr->type) { // depending on the expression's type
            case TYPE_EXP:
                freeExpr(ev.expval); // recursively call this function with the expression's child expression
                break;
            case TYPE_LAZ:
                freeLaz(ev.lazval);
                break;
            case TYPE_STR:
                freeStr(ev.strval);
                break;
            case TYPE_ARR:
                freeArr(ev.arrval);
                break;
            case TYPE_OBJ:
            	freeObj(ev.objval);
            case TYPE_FUN:
                freeFun(ev.funval);
                break;
        }
        if (next) { // if the next expression should be freed
            freeExpr(expr->next); // recursively call this function with the expression's next expression
        }
        free(expr); // free the expression itself
    }
    
    return 0;
}
예제 #2
0
/* emit_html_label:
 */
void
emit_html_label(GVJ_t * job, htmllabel_t * lp, textlabel_t * tp)
{
    htmlenv_t env;

    allocObj (job);
    env.pos = tp->pos;
    env.finfo.color = tp->fontcolor;
    env.finfo.name = tp->fontname;
    env.finfo.size = tp->fontsize;
    env.finfo.size = tp->fontsize;
    env.imgscale = agget (job->obj->u.n, "imagescale");
    env.objid = job->obj->id;
    env.objid_set = 0;
    if ((env.imgscale == NULL) || (env.imgscale[0] == '\0'))
	env.imgscale = "false";
    if (lp->kind == HTML_TBL) {
	htmltbl_t *tbl = lp->u.tbl;

	/* set basic graphics context */
	/* Need to override line style set by node. */
	gvrender_set_style(job, job->gvc->defaultlinestyle);
	if (tbl->data.pencolor)
	    gvrender_set_pencolor(job, tbl->data.pencolor);
	else
	    gvrender_set_pencolor(job, DEFAULT_COLOR);
	emit_html_tbl(job, tbl, &env);
    } else {
	emit_html_txt(job, lp->u.txt, &env);
    }
    if (env.objid_set)
	free (env.objid);
    freeObj (job);
}
예제 #3
0
unsigned int collectGarbage(Memory mem) {
    Chunk c = memToChunk(mem);
    Metafreelist list = memToMeta(mem);
    if(c) {
        setZero(c);
        AddressSpace as = (AddressSpace) malloc(sizeof(addressspace));
        as->start = (RawPtr) c->start;
        as->end = (RawPtr)((char*)c + list->size);

        traverseStack(as, mf, c); 
        free (as);
        freeObj(mem, c);
        }
    return 0;
    }
예제 #4
0
파일: obj.c 프로젝트: chamun/CGII
int
cleanBeforeExit (int errorID, objObj * obj, FILE * obj_fp,
		 FILE * mtl_fp, nameIndex * mtlIndex, nameIndex * texIndex)
{
	if (errorID != 0)
	{
		/* clean obj data */
		freeObj (obj);
	}

	if (mtl_fp != NULL)
		fclose (mtl_fp);
	if (obj_fp != NULL)
		fclose (obj_fp);

	if (mtlIndex != NULL)
		free (mtlIndex);
	if (texIndex != NULL)
		free (texIndex);

	return errorID;
}