Example #1
0
void freeAll(struct parseNode *p)
{
    if(p!=NULL)
    {
        freeAll(p->next);
        if(p->type & 1)
            freeAll(p->dat.n);
        else
            free(p->dat.s);
        free(p);
    }
}
Example #2
0
void
freeAll_extra()
{
  freeAll();
  destroyDocumentStuff();
  parse();
}
Example #3
0
void printCells(int **cells)
{
    FILE *file;
    if (!file = fopen("solved.txt", "w+")) {
        puts("Error reading the solution");
        freeAll(cells);
        exit(1);
    }
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            if (j == 2 || j == 5) {
                printf("%d  ", cells[i][j]);
            }

            else {
                printf("%d ", cells[i][j]);
            }
        }
        if (i == 2 || i == 5)
            puts("\n");
        else
            puts("");
    }
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            fprintf(file, "%d ", cells[i][j]);
        }
        fprintf(file, "\n");
    }
    fclose(file);
}
Example #4
0
File: csim.c Project: R7R8/15213
int main(int argc, char ** argv){
	char ops;
	unsigned int address;
	int size;
	Set *headSet = NULL;
  	FILE *fp;

	getOpts(argc, argv);
	headSet = construction();
	fp = fopen(fileTrace, "r");
	if(fp == NULL){
		exit(1);
	}
	/*read each line from log*/
	 while (fscanf(fp, " %c %x, %d\n", &ops, &address, &size) != EOF){
	 	if(ops == 'M'){
	 		search(headSet, address);
	 		numHits++;
	 	}else if(ops == 'L' || ops == 'S'){
	 		search(headSet, address);
	 	}
	 }

	 freeAll(headSet);
	 printSummary(numHits, numMiss, numEvic);
	 fclose(fp);

	 return 0; 	
}
Example #5
0
int main(int argc, char *argv[])
{
    DIR *dirp;
    struct dirent *dp;

    Status *status;
    Status *previous = NULL;

    dirp = opendir("/proc/");

    while ((dp = readdir(dirp)) != NULL) {

        if (isNumericString(dp->d_name)) {

            status = getProcessStatus(atoi(dp->d_name));

            if (status != NULL) {
                insertProcess(previous, status);
                previous = status;
            }

        }

    }

    draw(status);

    freeAll(previous);
    closedir(dirp);

    exit(EXIT_SUCCESS);
}
void TNSCollection::shutDown()
{
    if( shouldDelete )
        freeAll();
    setLimit(0);
    TObject::shutDown();
}
Example #7
0
void GraphicsManager::shutDown(void)
{
	endwin();
	freeAll();

	log->writeLog("GraphicsManager: Shut Down");
}
Example #8
0
bool ThreeLogGroupMgr::remove()
{
    if(m_poLogGroupData->exist())
        m_poLogGroupData->remove();

    if(m_poLogGroupIndex->exist()) 
        m_poLogGroupIndex->remove();

    for(int i=1;i<=m_iMaxGroup;i++)
    {
        if(m_poInfoDataAll[i]->exist())
            m_poInfoDataAll[i]->remove();
    }
    
    for(int i=1;i<=m_iMaxGroup;i++)
    {
        if(m_poInfoIndexAll[i]->exist())
            m_poInfoIndexAll[i]->remove();
    }
    m_bAttached = false;

    freeAll();

    return true;
}
Example #9
0
int main(int argc, char *argv[]) {
    /* Test the list implementation */
    struct ListElement* head = ListElement(0);
    append(head, 1);
    append(head, 2);
    append(head, 3);
    printList(head);
    deleteElem(&head, 2);
    puts("Aus der Mitte gelöscht:");
    printList(head);
    deleteElem(&head, 0);
    puts("Vom Anfang gelöscht:");
    printList(head);
    deleteElem(&head, 1);
    puts("Vom Ende gelöscht:");
    printList(head);
    freeAll(&head);
    /* Test the tree implementation */
    struct Node* root = Node(24);
    insert(&root, 23);
    insert(&root, 31);
    insert(&root, 19);
    insert(&root, 3);
    insert(&root, 84);
    insert(&root, 46);
    insert(&root, 12);
    printTree(root);
    freeTree(&root);
    return 0;
}
Example #10
0
MODEL::~MODEL(void)
{
	if(myMesh!= NULL){
		delete myMesh;
	}
	freeAll();
}
Example #11
0
File: rash.c Project: MStoykov/RASH
void executeFile(char * filename){
	struct codeBreaking cb ;
	init(&(cb.argv));
	if ( (cb.fs = open(filename, O_RDONLY)) == -1){
		if (errno ==ENOENT){
			write (1,"ENOENT",6);
		} else if(errno ==EACCES) {
				write (1,"EACCES",6);
		} else if(errno == EEXIST) {
			write (1,"EEXIST", 6);
		} else {
			write (1,"UNKNOWN", 7);
		}
		return;
	}
	cb.command=NULL;
	char *c = malloc (sizeof c);
	cb.buf =malloc (sizeof *cb.buf * BUF_LEN);
	cb.len =0;
	while(1){
		cutCommand(&cb);
		if (cb.command == NULL) break;
		runTheCommand(&cb);
		freeAll(cb.argv);
		cb.command = NULL;
	}
	
	close (cb.fs);
}
Example #12
0
void sequencial(int id_matriz){
    struct timeval start,end;
    int i=0;
    //MATRIZES *matrizes = inicializaVariaveis(id_matriz,0);
    MATRIZES *matrizes = NULL;
    char name_arq[37];
    double tempo = 0;
    double tempo_aux=0;
    int n_interacoes=-1;
    double rowtest =0.0;
    for(i = 0 ; i < 10 ; ++i){
         matrizes = inicializaVariaveis(id_matriz,0);
        sprintf(name_arq,"out/%d/seq/%d_seqOp%d.txt",matrizes->number_matriz,
                        matrizes->number_matriz,i);


        FILE *arq_save = NULL;
        if( (arq_save=fopen(name_arq,"w")) == NULL){
            printf("File name_arq errou ao abir\n");
        }
        gettimeofday(&start,NULL);
        inicializaMetodo(matrizes);
        n_interacoes = inicioInteracaoSequencial(matrizes,arq_save);
        rowtest = rowTest(matrizes);


        gettimeofday(&end,NULL);
        tempo_aux =( ((double) ( ((end.tv_sec * 1000000 + end.tv_usec)
                                - (start.tv_sec * 1000000 + start.tv_usec))))/1000000);
        tempo +=tempo_aux;
        writeEndX(matrizes,arq_save);
        fprintf(arq_save, "Numero de Interacoes: %d\n",n_interacoes );
        fprintf(arq_save, "RowTest: %d => [%lf] =? %lf\n", matrizes->J_ROW_TEST, rowtest ,
                                                    matrizes->ROW_TEST[matrizes->J_ORDER]);
        fprintf(arq_save, "Tempo de Execucao: %lf\n",tempo_aux );
        fclose(arq_save);
        if(i != 9)
            freeAll(&matrizes);
    }
    printf("---------------------------------------------------------\n");
    printf("Iterations: %d\n", n_interacoes);
    printf("RowTest: %d => [%lf] =? %lf\n", matrizes->J_ROW_TEST, rowtest ,
                                                    matrizes->ROW_TEST[matrizes->J_ORDER]);
    printf("Tempo medio: %lf",tempo/10);
    printf("\n-------------------------------------------------------\n");
    freeAll(&matrizes);
}
Example #13
0
static void catchterm(int sig) {
	if (disconnectFromIPC(MAIN_ID) == ERROR) {
		destroyIPC(MAIN_ID);
	}
	destroySem(sem_id);
	freeAll();
	exit(0);
}
Example #14
0
void freePriority_queue(Priority_queue_p pq) {
	int i = 0;
	for(i = 0; i < PRIORITY_COUNT; i++) {
		freeAll(pq->Queue_List[i]);
	}
	free(pq);
	pq = NULL;
}
Example #15
0
void RhoBluetoothManager::rho_bluetooth_session_disconnect(const char* connected_device_name) {
	LOG(INFO)  + "RhoBluetoothManager::rho_bluetooth_session_disconnect("+connected_device_name+")";
	if (strcmp(connected_device_name, mConnectedDeviceName) != 0) {
		return;
	}
	freeAll();
	init();
	fireSessionCallBack(connected_device_name, RHO_BT_SESSION_DISCONNECT);
}
Example #16
0
/**
 * Initialize the isomorphism environment
 */
JNIEXPORT void JNICALL Java_com_uwemeding_connectivity_CompareAPI_initialize(
        JNIEnv * env,
        jobject obj) {
    freeAll();

    IMEnv *imEnv = initializeIMEnv();

    setIMEnv(env, obj, imEnv);
}
Example #17
0
EXTERN_C_START

/**
 * Finalize the native environment
 */
JNIEXPORT void JNICALL Java_com_uwemeding_connectivity_CompareAPI_finalizeEnv(
        JNIEnv * env,
        jobject obj) {
    freeAll();
}
Example #18
0
File: cOS.c Project: jiangeZh/myOS
parallelDo()
{
	cls();
	Program_Num = 4;
	CurrentPCBno = 1;
	freeAll();
	initPro();
	setClock();
	do2();
}
int main(int argc, char **argv)
{
    debugMode= debugSwitch(argv);//either TRUE or FALSE
    DIR           *theDirectory;
    struct dirent *aFile;
    char inFileName[12];
    FILE *inFile;
    content *tableofContents;//point to the structs
    int fileCount;//number of .txt files
    char sml[7]; //the user will specify small,medium or large
    int stringLength;
    int displayPairs;
    int mossSpace;
    

    intro();
    
    theDirectory=specifyDirLengthPairs(sml,&stringLength,&displayPairs);
    
    tableofContents= allocateSpaceStruct(fileCount=ListFileNames(theDirectory));
    
    readInFileNames(tableofContents, theDirectory, sml);
    
    combineDIRandTxtName(tableofContents, sml, fileCount);
    
    numbValidChar(tableofContents,fileCount);
    
    mallocSpaceChar (tableofContents, fileCount);
    
    readInChar(tableofContents,fileCount);
    
    numberofBlocks(tableofContents,stringLength,fileCount);
    
    mallocBlocksofChar(tableofContents,fileCount, stringLength);
    
    sortBlocksChar(tableofContents,fileCount);
    
    moss* mossKeeper=mossMalloc(fileCount,&mossSpace);

    int mKindex=0;
    while(mKindex<mossSpace)
    {
        //printf("mkindex::%d,,txtA:%d,,txtB::%d\n",mKindex ,mossKeeper[mKindex].txtNumA,mossKeeper[mKindex].txtNumB);
        
        Bsearch(mossKeeper,tableofContents,mKindex,stringLength);
        mKindex++;
    }
    
    diplayTop(displayPairs,mossKeeper,mossSpace,tableofContents);
    
    freeAll(tableofContents,fileCount,mossKeeper);
    
    return 0;
 
}
Example #20
0
BaseContestLog::~BaseContestLog()
{
   delete [] districtWorked;
   delete [] countryWorked;
   districtWorked = 0;
   countryWorked = 0;

   locs.freeAll();
   freeAll();
   closeFile();
}
Example #21
0
CSockPairEvent::~CSockPairEvent(void)
{
    try
    {
        freeAll();
    }
    catch(...)
    {

    }    
}
Example #22
0
void MODEL::update( void * src, meshMsg msg )
{
	if(msg == CONNECTIVITY_CHANGED){
		freeAll();
		//invalidateAll();
	}
	else if(msg == POS_CHANGED){
		unrefreshedStars();
	}

}
Example #23
0
void concorrente(int id_matriz,int n_threads){
    struct timeval start,end;
    MATRIZES *matrizes = NULL;
    int i;
    char name_arq[37];
    double tempo = 0;
    double tempo_aux=0;
    int n_interacoes;
    double rowtest =0.0;
    for(i = 0 ; i < 10 ; ++i){
	printf("interacao: %d\n",i);
        matrizes = inicializaVariaveis(id_matriz,n_threads);
        sprintf(name_arq,"out/%d/conc%d/%d_conc%dOp%d.txt",matrizes->number_matriz,
                        matrizes->n_threads,matrizes->number_matriz,matrizes->n_threads,i);
        FILE *arq_save = fopen(name_arq,"w");

        gettimeofday(&start,NULL);
        inicializaMetodo(matrizes);
        n_interacoes = inicioInteracaoConcorrente(matrizes,arq_save);
        rowtest = rowTest(matrizes);
        gettimeofday(&end,NULL);
        tempo_aux =( ((double) ( ((end.tv_sec * 1000000 + end.tv_usec)
                                - (start.tv_sec * 1000000 + start.tv_usec))))/1000000);
        tempo +=tempo_aux;
        writeEndX(matrizes,arq_save);
        fprintf(arq_save, "Numero de Interacoes: %d\n", n_interacoes );
        fprintf(arq_save, "RowTest: %d => [%lf] =? %lf\n", matrizes->J_ROW_TEST, rowtest ,
                                                    matrizes->ROW_TEST[matrizes->J_ORDER]);
        fprintf(arq_save, "Tempo de Execucao: %lf\n",tempo_aux );
        fclose(arq_save);
        if(i !=9)
            freeAll(&matrizes);
    }
    printf("---------------------------------------------------------\n");
    printf("Iterations: %d\n",n_interacoes );
    printf("RowTest: %d => [%lf] =? %lf\n", matrizes->J_ROW_TEST, rowtest ,
                                                    matrizes->ROW_TEST[matrizes->J_ORDER]);
    printf("Tempo medio: %lf\n",tempo/10);
    printf("-------------------------------------------------------\n\n");
    freeAll(&matrizes);
}
Example #24
0
/* fermer : retourne 0 si on a cliqué sur le bouton avance rapide sinon retourne 1 	*/
int clickExit(LMonster* p_lmonster, LShot* p_lshot, LTower* p_ltower, LFileTower* p_lfileTower, Map* map, Interface* interface, float x, float y, int aide) {
	
	if(aide == 0) {
		if(x <= 790 && x >= 760 && y <= 45 && y >= 15) {
			freeAll (p_lmonster, p_lshot, p_ltower, p_lfileTower, map, interface);
			return 0;
		}
	}

	return 1;

}
Example #25
0
void GameSound::close()
{
#ifdef	HAVE_SDL_SDL_MIXER_H
	if( flagEnable ){
		Mix_HaltChannel( -1 );

# ifndef	D_MFC
		freeAll();
# endif
	}
#endif

	flagEnable = false;
}
Example #26
0
int main(int argc, char *argv[])
{
    int **cells = (int **) calloc(9, sizeof(int *));
    for (int i = 0; i < 9; i++)
        cells[i] = (int *) calloc(9, sizeof(int));
    if (argc > 1)
        if (strcmp(argv[1], "-h") == 0) {
            help();
            freeAll(cells);
            return EXIT_SUCCESS;
        }
    load(cells);
    if (SudokuSolution(cells, 0, 0) == 0) {
        puts("Improper task. Try again");
        freeAll(cells);
        return EXIT_SUCCESS;
    } else {
        puts("There's the answer:");
        printCells(cells);
    }
    freeAll(cells);
    return EXIT_SUCCESS;
}
Example #27
0
void NewLoader::open(QString path) {
    if(!dm->existsInCurrentDir(path)) {
        freeAll();
        preloadTarget = 0;
        loadTarget = 0;
        dm->setFile(path);
        reinitCache();
    } else {
        freeAuto();
        dm->setFile(path);
    }
    emit loadStarted();
    doLoad(dm->currentFilePos());
}
Example #28
0
void load(int **cells)
{

    FILE *file;
    if (!file = fopen("task.txt", "r+")) {
        puts("Error reading task file");
        freeAll(cells);
        exit(1);
    }
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            fscanf(file, "%d", &cells[i][j]);
        }
    }
    fclose(file);
}
Example #29
0
static void catchint(int signal) {
	int i;
	for (i = 0; i < processID->cantPids; i++) {
		wait(0); // Waits for child processes to abort
	}

	printf("Aborting Simulation\n");
	freeAll();
	if (disconnectFromIPC(MAIN_ID) == ERROR) {
		destroyIPC(MAIN_ID);
	}
	destroySem(sem_id);

	exit(1);

}
Example #30
0
void Scene::UpdateLoop()
{
	double lastTime = 0;
	glfwSetTime(0);
	for (unsigned int i = 0; i < m_allObjects.size(); i++)
	{
		m_allObjects[i]->Start();
	}

	while (true)
	{
		bool shouldBeClose = true;
		for (Screen* screen : m_screens)
		{
			if (!screen->ShouldClose())
				shouldBeClose = false;
		}
		if (shouldBeClose)
			break;
		glfwPollEvents();
		double currentTime = glfwGetTime();
		double delta = currentTime - lastTime;
		lastTime = currentTime;

		for (unsigned int i = 0; i < m_allObjects.size(); i++)
		{
			m_allObjects[i]->Update(delta);
		}
		for (Screen* screen : m_screens)
		{
			for (Camera* camera : m_cameras)
			{
				vector<string> layers = camera->GetAllLayers();
				for (string layer : layers)
				{
					vector<unsigned int>* layerObjects;
					if(FindInUnorderMapValueByKey(m_layers , layer , &layerObjects))
						camera->Renderer(*layerObjects , m_allObjects, screen);
				}
			}
			screen->Clear();
		}
	}
	freeAll();
}