Exemple #1
0
bool 
cpwFreeContext( pCpw * cpw ) 
{
    if ( cpw == null ) return false;
    if ( *cpw == null ) return true;

    cpw_glextensions_exit( *cpw );  /* free resources */
    cpw_primitives_exit( *cpw );    /* free primitive drawing resources */
    cpw_videosettings_exit( *cpw ); /* restore pre-gamemode settings */
    cpw_timers_exit( *cpw );        /* kill timers */
    cpw_window_close( *cpw );       /* send close events to open windows */
    cpw_event_exit( *cpw );         /* flushs all window events */
    cpw_menus_exit( *cpw );         /* destroy all menus */
    cpw_window_exit( *cpw );        /* manually destroys open windows */
    cpw_font_exit( *cpw );          /* free font library */
    cpw_perftracker_exit( *cpw );   /* dump stats to print handler */
    cpw_joystick_exit( *cpw );      /* shutdown joystick interface */
    cpw_localhost_exit( *cpw );     /* shutdonw lh adapter */
    cpw_init_exit( *cpw );          /* shutdown cpw */
    
    freeStr( &(*cpw)->cpw_driverinfo ); /* free cpwGet string for driver info if it's allocated */

    cpwfree( *cpw );                /* free state memory */
    *cpw = 0;                       /* return null pointer */

    return true;
}
Exemple #2
0
/*! 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;
}
Exemple #3
0
/*! Frees from memory the given argument
	@param arg		the argument to free from memory
	@return			0
*/
bool freeArg (argument* arg) {
	freeStr(arg->name);
	freeTypelist(arg->types);
	freeExpr(arg->initial);
	free(arg);
	
	return 0;
}
Exemple #4
0
/*! Frees from memory the given list of strings
	@param sl		the list of strings to free from memory
	@return			0
*/
bool freeStringlist (stringlist* sl) {
	stringlist* next_sl;
	while (sl != NULL) {
		next_sl = sl->next;
		freeStr(sl->str);
		free(sl);
		sl = next_sl;
	}
	
	return 0;
}