/* * Changes the size of the buffer to contain at least newsize bytes */ void change_buffer_size(const size_t newsize) { if ( BUFFER_PTR == NULL ) { if ((BUFFER_PTR = malloc( BLOCK_SIZE < newsize ? newsize : BLOCK_SIZE)) == NULL) { YAP_Error(0,0,"Prolog2Term: Out of memory.\n"); #ifdef MPI MPI_Finalize(); #endif YAP_Exit( 1 ); } } else if ((BUFFER_SIZE>=BLOCK_SIZE && BUFFER_SIZE>=newsize) ) { return; } else if ((BUFFER_PTR = realloc( BUFFER_PTR, newsize)) == NULL) { YAP_Error(0,0,"Prolog2Term: Out of memory.\n"); #ifdef MPI MPI_Finalize(); #endif YAP_Exit( 1 ); } BUFFER_SIZE=newsize; }
/* * Adds 'space' to the size of the currently allocated buffer */ static void expand_buffer(const size_t space ) { BUFFER_PTR = realloc( BUFFER_PTR, BUFFER_SIZE + space ); if( BUFFER_PTR == NULL ) { YAP_Error(0,0,"Prolog2Term: Out of memory.\n"); #ifdef MPI MPI_Finalize(); #endif YAP_Exit( 1 ); } BUFFER_SIZE+=space; }
/* * Changes the size of the buffer to contain at least newsize bytes */ void change_buffer_size(const size_t newsize) { if ( BUFFER_SIZE>=BLOCK_SIZE && BUFFER_SIZE>newsize) return; if(BUFFER_PTR!=NULL) free(BUFFER_PTR); BUFFER_PTR = (char*)malloc(newsize); if( BUFFER_PTR == NULL ) { YAP_Error(0,0,"Prolog2Term: Out of memory.\n"); #ifdef MPI MPI_Finalize(); #endif YAP_Exit( 1 ); } BUFFER_SIZE=newsize; }
/* * Adds 'space' to the size of the currently allocated buffer */ static void expand_buffer(const size_t space ) { char *oldblock; // BUFFER_PTR = realloc( BUFFER_PTR, BUFFER_SIZE + space ); oldblock= BUFFER_PTR; BUFFER_PTR = (char*)malloc( BUFFER_SIZE + space ); if( BUFFER_PTR == NULL ) { YAP_Error(0,0,"Prolog2Term: Out of memory.\n"); #ifdef MPI MPI_Finalize(); #endif YAP_Exit( 1 ); } memcpy(BUFFER_PTR,oldblock,BUFFER_SIZE); if(oldblock!=NULL) free(oldblock); BUFFER_SIZE+=space; }
static void exec_top_level(int BootMode, YAP_init_args *iap) { YAP_Term atomfalse; YAP_Atom livegoal; if (BootMode == YAP_BOOT_FROM_SAVED_STACKS) { /* continue executing from the frozen stacks */ YAP_ContinueGoal(); } livegoal = YAP_FullLookupAtom("$live"); /* the top-level is now ready */ /* read it before case someone, that is, Ashwin, hides the atom false away ;-). */ atomfalse = YAP_MkAtomTerm(YAP_FullLookupAtom("$false")); while (YAP_GetValue(livegoal) != atomfalse) { YAP_Reset(YAP_FULL_RESET); do_top_goal(YAP_MkAtomTerm(livegoal)); livegoal = YAP_FullLookupAtom("$live"); } YAP_Exit(EXIT_SUCCESS); }