static int private_link_archive( const void* buildParameters, const void* providerContext, const void* targetIDirectory ) { int status = 1; const BuildParameters* parameters = (BuildParameters*) buildParameters; const ProviderContext* context = (ProviderContext*) providerContext; const IDirectory* target = (IDirectory*) targetIDirectory; const char* target_location = Path_getCondensed( Directory_getRealPath( target ) ); // Linux: ar rcs <LIBNAME> <OBJECTS>... // Win32: lib /OUT:<LIBNAME> <OBJECTS>... char* name = CharString_between( context->package_name, "", "-" ); if ( !name ) { name = new_CharString( context->package_name ); } { char* libname = CharString_cat2( name, ".a" ); char* full_lib_location = CharString_cat3( target_location, "/lib/", libname ); char* obj_dir = CharString_cat2( target_location, "/obj/" ); if ( 0 < List_count( context->objectFiles ) ) { Command* command; IList* arguments = new_List(); IList* native_arguments; List_copyItem( arguments, context->archiver ); List_copyItem( arguments, "rcs" ); List_copyItem( arguments, full_lib_location ); addFlags( arguments, obj_dir, context->objectFiles ); native_arguments = Path_ConvertListToNative( arguments ); command = new_Command( context->archiver, (const char**) native_arguments->items ); Command_print( command, stderr ); // if ( !BuildParameters_isNo( parameters ) && Command_run( command ) && Command_waitFor( command ) ) // { // status &= Command_getResult( command ); // } else { // fprintf( stderr, "failed: " ); // Command_print( command, stderr ); // } free_Command( command ); free_List( native_arguments ); free_List( arguments ); } free_CharString( obj_dir ); free_CharString( full_lib_location ); free_CharString( libname ); } free_CharString( name ); return status; }
/** distrugge una tabella hash deallocando tutta la memoria occupata \param pt puntatore al puntatore della tabella da distruggere nota: mette a NULL il puntatore \c *pt */ void free_hashTable (hashTable_t ** pt) { list_t ** listItr_pp = NULL; int i = 0; /* controllo valore dell'argomento */ if (NULL == pt) { errno = EINVAL; return ; } /* controllo valore del puntatore alla struttura hash riferita dal * paramentro ed il valore del puntatore alla tabella hash nella * struttura */ if (NULL == *pt || NULL == (*pt)->table) { errno = EFAULT; return ; } listItr_pp = (*pt)->table; /* deallocazione delle liste */ for (i=0; i<(*pt)->size; i++) free_List(listItr_pp+i); /* deallocazione della tabella */ free((*pt)->table); /* deallocazione della struttura della tabella hash */ free(*pt); *pt = NULL; }
int main() { Link Head; Head=creat_List(Head); if(search_List(8, Head)) { printf("searchtime= %d", searchtime); } else printf("NO FIND!!"); if(Head!=NULL) free_List(Head); reuturn 0; }
int SuperDirectory_refresh( ISuperDirectory* self ) { int status = 1; if ( self->volumes ) { free_List( self->volumes ); } self->volumes = new_List(); List_copyItem( self->volumes, "/" ); return status; }
/** inserisce una nuova coppia (key, payload) nella hash table (se non c'e' gia') \param t la tabella cui aggiungere \param key la chiave \param payload l'informazione \retval -1 se si sono verificati errori (errno settato opportunamente) \retval 0 se l'inserimento \`e andato a buon fine SP ricordarsi di controllare se (in caso di errore) si lascia la situazione consistente o si fa casino nella lista .... */ int add_hashElement(hashTable_t * t,void * key, void* payload ) { int index = 0; /* controllo valore dei parametri */ if (!t || !key || !payload || !(t->table)) { errno = EINVAL; return -1; } /* indice della tabella hash per la chiave da inserire */ index = t->hash(key, t->size); /* verifica che sia allocatanella, nella tabella hash, la lista per * l'indice hash della chiave da inserire */ if (NULL == *(t->table+index)) { /* crea la lista per l'indice index della tablella */ if (NULL == (*(t->table+index) = new_List(t->compare, t->copyk, t->copyp))) return -1; /* impossibile creare la lista in index di hash table * (memoria non disponibile) */ } /* aggiungi un nuovo elemento alla lista (key, payload) */ errno = 0; if (-1 == add_ListElement(*(t->table+index), key, payload)) { /* dato che NULL != { *(t->table+index), key, payload } * allora e' impossibile aggiungere un nuovo elemento * - perche' la memoria non e' disponibile * - perche' esiste gia' un elemento con chiave key * in entrambi i casi errno viene opportunamente impostato * da add_ListElement */ if (NULL == (*(t->table+index))->head) {/* <================================================== ACCESSO AI CAMPI DELLA STRUTTURA LIST_T */ /* la lista dell'indice corrispondente alla nuova chiave e' * vuota, cio' implica che e' stata allocata da questa * insersione e deve essere deallocata, in quanto l'insersione * e' fallita. * * nota: la free_List imposta a NULL il valore del puntatore * riferito dal puntatore passato per argomento, quindi * *(t->table+index) assumera' NULL, che significa lista non * presente per l'indice index della tabella hash. */ free_List(t->table+index); } return -1; } return 0; }
/** elimina l'elemento di chiave (key) deallocando la memoria \param t puntatore alla lista \param key la chiave \retval -1 se si sono verificati errori (errno settato opportunamente) \retval 0 se l'esecuzione e' stata corretta */ int remove_hashElement(hashTable_t * t, void * key) { int key_index = 0; /* controllo valore argomenti */ if (NULL == t || NULL == key) { errno = EINVAL; return -1; } /* conrollo valore del puntatore alla tabella hash */ if (NULL == t->table) { errno = EFAULT; return -1; } /* calcola l'indice per la chiave da rimuovere dalla tabella hash */ key_index = t->hash(key, t->size); /* se la lista dell'indice corrispondente alla chiave da rimuovere * non e' vuota, allora viene invocata la remove sulla questa lista * per la chiave key */ if (NULL == *(t->table+key_index)) return 0; /* l'indice della tabella hash corrispondente alla * chiave e' privo di elementi */ else if (-1 == remove_ListElement(*(t->table+key_index), key)) return -1; /* non dovrebbe mai verificarsi */ /* l'elemento di chiave key e' stato rimosso se era presente nella * hash table * * nota: se la lista in index della tabella hash e' vuota occorre * deallocarola */ if (NULL == (*(t->table+key_index))->head) /* <================================================== ACCESSO AI CAMPI DELLA STRUTTURA LIST_T */ free_List(t->table+key_index); /* dealloca la lista in key_index * diventata vuota dopo la remove */ return 0; }
/* free student list */ void free_StudentList (StudentList* slist) { free_List(slist -> list); free(slist); }
static int private_link_executable( const void* buildParameters, const void* providerContext, const void* targetIDirectory ) { // fprintf( stdout, "ISLabs::linux-gnu::gnu::link()\n" ); bool status = 1; const BuildParameters* parameters = (BuildParameters*) buildParameters; const ProviderContext* context = (ProviderContext*) providerContext; const IDirectory* target = (IDirectory*) targetIDirectory; SoName* so_name = generateSoName( context->package_name, context->isLib ); char* target_location_obj = CharString_cat2( Path_getCondensed( Directory_getRealPath( target ) ), "/obj/" ); char* target_location_bin_short = CharString_cat3( Path_getCondensed( Directory_getRealPath( target ) ), "/bin/", so_name->short_name ); Command* command; IList* arguments = new_List(); IList* native_arguments; // Linker List_copyItem( arguments, context->linker ); // Linker flags //if ( !BuildParameters_isRelease( parameters ) ) //{ // List_copyItem( arguments, "-Wl,-G" ); //} //List_copyItem( arguments, "-shared" ); // Object files: need to be before archive libraries so // symbols can be found. addFlags( arguments, target_location_obj, context->objectFiles ); // System library directories // addFlags( arguments, "-L", context->systemLibraryDirs ); if ( BuildParameters_isMonolithic( parameters ) ) { addFlags( arguments, "", context->unix_archives ); addFlags( arguments, "-l", context->system_libraries ); } else { addFlags( arguments, "-L", context->libraryDirs ); addFlags( arguments, "-l", context->libraries ); } List_addList( arguments, BuildParameters_getGlobal( parameters )->LFLAGS ); List_addList( arguments, BuildParameters_getGlobal( parameters )->LDFLAGS ); List_copyItem( arguments, "-Wl,-R$ORIGIN" ); List_copyItem( arguments, "-Wl,-R$ORIGIN/../lib" ); if ( BuildParameters_isDeep( parameters ) ) { addFlags( arguments, "-Wl,-R$ORIGIN/../", context->runtimeLibraryDirs ); } //List_copyItem( arguments, "-Wl,-soname" ); //List_addItem( arguments, CharString_cat2( "-Wl,", so_name->long_name ) ); List_copyItem( arguments, "-o" ); List_copyItem( arguments, target_location_bin_short ); native_arguments = Path_ConvertListToNative( arguments ); command = new_Command( context->linker, (const char**) native_arguments->items ); Command_print( command, stderr ); // if ( BuildParameters_getVerbosity( parameters ) ) // { // Command_print( command, stderr ); // } // // if ( !BuildParameters_isNo( parameters ) && Command_run( command ) && Command_waitFor( command ) ) // { // status &= Command_getResult( command ); // } else { // fprintf( stderr, "failed: " ); // Command_print( command, stderr ); // } free_Command( command ); free_List( native_arguments ); free_List( arguments ); free_CharString( target_location_obj ); free_CharString( target_location_bin_short ); return status; }
void main_menu(void) { char option; char sign; system("cls"); switch(language) { case '1' : { printf(" 学生成绩管理系统\n"); printf(" 来自:Dack"); printf("================================================================================\n"); printf("1.录入学生信息\n"); printf("2.显示当前记录在册的学生信息\n"); printf("3.删除学生信息\n"); printf("4.排序学生信息\n"); printf("5.整理学生信息\n"); printf("6.查找学生信息\n"); printf("7.结束程序\n\n"); } break; case '2' : { printf(" Student achievement management system\n"); printf(" By Dack"); printf("================================================================================\n"); printf("1.School student achievement\n"); printf("2.According to the existing student achievement\n"); printf("3.Delete student achievement\n"); printf("4.Sort student achievement\n"); printf("5.Order the information from the students\n"); printf("6.To find the student information\n"); printf("7.End of operation\n\n"); } break; case '3' : { printf(" 生徒の成績管理システム\n"); printf(" 出自:dack"); printf("================================================================================\n"); printf("1.学生の成績を入力\n"); printf("2.によると現在の存在学生の成績を出した\n"); printf("3.学生の個人情報を削除した」と\n"); printf("4.序列化の学生の個人情報\n"); printf("5.学生の個人情報を整理して\n"); printf("6.学生の個人情報の検索を\n"); printf("7.笲︽を終えた\n\n"); } break; } do { switch(language) { case '1' : { printf("请输入序号 : "); } break; case '2' : { printf("Please enter the serial number : "); } break; case '3' : { printf("番号を入力してください : "); } break; } fflush(stdin); scanf_s("%1c",&option); fflush(stdin); if(option<'1'||option>'7'){ switch(language) { case '1' : { printf("错误!你想结束程序吗 ?\n"); printf("请输入 Y 或者 N : "); } break; case '2' : { printf("Error! Do you want finish the program?\n"); printf("Please enter the Y or N : "); } break; case '3' : { printf("誤ったもので、あなたは终わりにプログラムだったのだろうか?\n"); printf("Y あるいは Nで入力してください : "); } break; } scanf_s("%c",&sign); if(toupper(sign)!='N') exit(0); } }while(option<'1'||option>'7'); fflush(stdin); switch(option) { case '1' : entry(); break; case '2' : according(); break; case '3' : expurgate(); break; case '4' : sequencing(); break; case '5' : dity(); break; case '6' : search(); break; case '7' : free_List(); exit(0); break; } }