コード例 #1
0
ファイル: context.c プロジェクト: moses-palmer/InAmazing3D
void
context_free(Context *context)
{
    /* Make sure that the context is passed */
    if (!context) {
        return;
    }

    if (context->maze.data) {
        maze_free(context->maze.data);
        context->maze.data = NULL;
    }

    if (context->stereo.zbuffer) {
        stereo_zbuffer_free(context->stereo.zbuffer);
        context->stereo.zbuffer = NULL;
    }

    if (context->stereo.effect) {
        stereo_pattern_effect_free(context->stereo.effect);
        context->stereo.effect = NULL;
    }

    if (context->stereo.image) {
        stereo_image_free(context->stereo.image);
        context->stereo.image = NULL;
    }

    glDeleteTextures(sizeof(context->gl.textures) / sizeof(GLuint),
        context->gl.textures);
    glDeleteRenderbuffers(sizeof(context->gl.renderbuffers) / sizeof(GLuint),
        context->gl.renderbuffers);
    glDeleteFramebuffers(sizeof(context->gl.framebuffers) / sizeof(GLuint),
        context->gl.framebuffers);
}
コード例 #2
0
ファイル: main.c プロジェクト: robinhouston/mazing
void print_maze(int width, int height, mpz_t index)
{
    maze_t *maze = maze_by_index(width, height, index);
    if (!maze) {
        fprintf(stderr, "Index number out of range\n");
        exit(EX_USAGE);
    }
    maze_print(maze);
    maze_free(maze);
}
コード例 #3
0
ファイル: env.c プロジェクト: rpreen/xcs
void env_free()
{
	switch(env) {
		case MUX:
			mux_free();
			break;
		case MAZE:
			maze_free();
			break;
	}
}
コード例 #4
0
ファイル: p2_e3.c プロジェクト: OscarGB/Prog-2
int main (int argc, char *argv[]){
	FILE *f = NULL;
	Maze *pmaze = NULL;
	Point *ppoint = NULL;
	Stack *pila = NULL; /*Pila donde guardaremos el camino*/
	f = fopen(argv[1], "r"); /*Abrimos el archivo en escritura para no modificar su contenido*/
 	if(!f){
 		printf("Error de apertura de fichero\n");
 		return -1;
 	}
 	pmaze = maze_ini();
 	if(!pmaze){
 		printf("Error reserva pmaze\n");
 		fclose(f);
 		return -1;
 	}
 	if(!maze_read(f, pmaze)){ /*Leemos el archivo para guardar el laberinto*/
 		fclose(f);
 		printf("Error lectura maze\n");
 		maze_free(pmaze);
 		return -1;
 	}
 	fclose(f);
 	ppoint = maze_getInput(pmaze); /*Conseguimos el input de nuestro laberinto*/
 	if(!ppoint){
 		printf("Error ppoint input\n");
 		maze_free(pmaze);
 		return -1;
 	}
 	pila = Recorrer(pmaze, ppoint);
 	if (!pila){ /*Si la pila esta vacía es porque no ha encontrado camino o ha ocurrido algún error*/
 		printf("No es posible encontrar un camino\n");
 	}
 	else{
 		printf("Es posible encontrar un camino\n");
 		stack_print(stdout, pila);
 	}
 	stack_free(pila);
 	maze_free(pmaze);
	return 0;
}
コード例 #5
0
ファイル: labyrinth.c プロジェクト: chrisseaton/stamp
/* =============================================================================
 * main
 * =============================================================================
 */
MAIN(argc, argv)
{
    GOTO_REAL();

    /*
     * Initialization
     */
    parseArgs(argc, (char** const)argv);
    long numThread = global_params[PARAM_THREAD];
    SIM_GET_NUM_CPU(numThread);
    TM_STARTUP(numThread);
    P_MEMORY_STARTUP(numThread);
    thread_startup(numThread);
    maze_t* mazePtr = maze_alloc();
    assert(mazePtr);
    long numPathToRoute = maze_read(mazePtr, global_inputFile);
    router_t* routerPtr = router_alloc(global_params[PARAM_XCOST],
                                       global_params[PARAM_YCOST],
                                       global_params[PARAM_ZCOST],
                                       global_params[PARAM_BENDCOST]);
    assert(routerPtr);
    list_t* pathVectorListPtr = list_alloc(NULL);
    assert(pathVectorListPtr);

    /*
     * Run transactions
     */
    router_solve_arg_t routerArg = {routerPtr, mazePtr, pathVectorListPtr};
    TIMER_T startTime;
    TIMER_READ(startTime);
    GOTO_SIM();
#ifdef OTM
#pragma omp parallel
    {
        router_solve((void *)&routerArg);
    }
#else
    thread_start(router_solve, (void*)&routerArg);
#endif
    GOTO_REAL();
    TIMER_T stopTime;
    TIMER_READ(stopTime);

    long numPathRouted = 0;
    list_iter_t it;
    list_iter_reset(&it, pathVectorListPtr);
    while (list_iter_hasNext(&it, pathVectorListPtr)) {
        vector_t* pathVectorPtr = (vector_t*)list_iter_next(&it, pathVectorListPtr);
        numPathRouted += vector_getSize(pathVectorPtr);
    }
    printf("Paths routed    = %li\n", numPathRouted);
    printf("Elapsed time    = %f seconds\n", TIMER_DIFF_SECONDS(startTime, stopTime));

    /*
     * Check solution and clean up
     */
    assert(numPathRouted <= numPathToRoute);
    bool_t status = maze_checkPaths(mazePtr, pathVectorListPtr, global_doPrint);
    assert(status == TRUE);
    puts("Verification passed.");
    maze_free(mazePtr);
    router_free(routerPtr);

    TM_SHUTDOWN();
    P_MEMORY_SHUTDOWN();

    GOTO_SIM();

    thread_shutdown();


    MAIN_RETURN(0);
}
コード例 #6
0
ファイル: labyrinth.c プロジェクト: jaingaurav/rstm
/* =============================================================================
 * main
 * =============================================================================
 */
MAIN(argc, argv)
{
    /*
     * Initialization
     */
    parseArgs(argc, (char** const)argv);
    long numThread = global_params[PARAM_THREAD];
    SIM_GET_NUM_CPU(numThread);
    TM_STARTUP(numThread);
    P_MEMORY_STARTUP(numThread);
    thread_startup(numThread);
    maze_t* mazePtr = maze_alloc();
    assert(mazePtr);
    long numPathToRoute = maze_read(mazePtr, global_inputFile);
    router_t* routerPtr = router_alloc(global_params[PARAM_XCOST],
                                       global_params[PARAM_YCOST],
                                       global_params[PARAM_ZCOST],
                                       global_params[PARAM_BENDCOST]);
    assert(routerPtr);
    list_t* pathVectorListPtr = list_alloc(NULL);
    assert(pathVectorListPtr);

    /*
     * Run transactions
     */
    router_solve_arg_t routerArg = {routerPtr, mazePtr, pathVectorListPtr};
    // NB: Since ASF/PTLSim "REAL" is native execution, and since we are using
    //     wallclock time, we want to be sure we read time inside the
    //     simulator, or else we report native cycles spent on the benchmark
    //     instead of simulator cycles.
    GOTO_SIM();
    TIMER_T startTime;
    TIMER_READ(startTime);
#ifdef OTM
#pragma omp parallel
    {
        router_solve((void *)&routerArg);
    }
#else
    thread_start(router_solve, (void*)&routerArg);
#endif
    TIMER_T stopTime;
    TIMER_READ(stopTime);
    // NB: As above, timer reads must be done inside of the simulated region
    //     for PTLSim/ASF
    GOTO_REAL();

    long numPathRouted = 0;
    list_iter_t it;
    list_iter_reset(&it, pathVectorListPtr);
    while (list_iter_hasNext(&it, pathVectorListPtr)) {
        vector_t* pathVectorPtr = (vector_t*)list_iter_next(&it, pathVectorListPtr);
        numPathRouted += vector_getSize(pathVectorPtr);
    }
    printf("Paths routed    = %li\n", numPathRouted);
    printf("Elapsed time    = %f seconds\n", TIMER_DIFF_SECONDS(startTime, stopTime));

    /*
     * Check solution and clean up
     */
    assert(numPathRouted <= numPathToRoute);
    bool status = maze_checkPaths(mazePtr, pathVectorListPtr, global_doPrint);
    assert(status);
    puts("Verification passed.");
    maze_free(mazePtr);
    router_free(routerPtr);

    TM_SHUTDOWN();
    P_MEMORY_SHUTDOWN();

    thread_shutdown();


    MAIN_RETURN(0);
}
コード例 #7
0
ファイル: test_maze.c プロジェクト: jleedev/maze-gl
int main(void) {
	srandom(time(NULL));
	maze *m = maze_new(4, 5);
	maze_print(m);
	maze_free(m);
}