diff -r 6171f0bad318 -r f7b49b2c5d84 project_files/frontlib/model/teamlist.c --- a/project_files/frontlib/model/teamlist.c Wed Jun 27 22:52:19 2012 +0200 +++ b/project_files/frontlib/model/teamlist.c Thu Jul 05 00:33:24 2012 +0200 @@ -53,9 +53,8 @@ } int flib_teamlist_insert(flib_teamlist *list, flib_team *team, int pos) { - if(!list || !team) { - flib_log_e("null parameter in flib_teamlist_insert"); - } else if(!insertTeam(&list->teams, &list->teamCount, team, pos)) { + if(!log_badargs_if2(list==NULL, team==NULL) + && !insertTeam(&list->teams, &list->teamCount, team, pos)) { flib_team_retain(team); return 0; } @@ -64,9 +63,7 @@ int flib_teamlist_delete(flib_teamlist *list, const char *name) { int result = -1; - if(!list || !name) { - flib_log_e("null parameter in flib_teamlist_delete"); - } else { + if(!log_badargs_if2(list==NULL, name==NULL)) { int itemid = findTeam(list, name); if(itemid>=0) { flib_team *team = list->teams[itemid]; @@ -81,9 +78,7 @@ flib_team *flib_teamlist_find(const flib_teamlist *list, const char *name) { flib_team *result = NULL; - if(!list || !name) { - flib_log_e("null parameter in flib_teamlist_find"); - } else { + if(!log_badargs_if2(list==NULL, name==NULL)) { int itemid = findTeam(list, name); if(itemid>=0) { result = list->teams[itemid]; @@ -93,9 +88,7 @@ } void flib_teamlist_clear(flib_teamlist *list) { - if(!list) { - flib_log_e("null parameter in flib_teamlist_clear"); - } else { + if(!log_badargs_if(list==NULL)) { for(int i=0; iteamCount; i++) { flib_team_release(list->teams[i]); } @@ -104,3 +97,27 @@ list->teamCount = 0; } } + +flib_teamlist *flib_teamlist_copy(flib_teamlist *list) { + if(!list) { + return NULL; + } + flib_teamlist *result = flib_teamlist_create(); + if(result) { + bool error = false; + for(int i=0; !error && iteamCount; i++) { + flib_team *teamcopy = flib_team_copy(list->teams[i]); + if(!teamcopy) { + error = true; + } else { + error |= flib_teamlist_insert(result, teamcopy, i); + } + flib_team_release(teamcopy); + } + if(error) { + flib_teamlist_destroy(result); + result = NULL; + } + } + return result; +}