Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > ListOfArrays
diff ListOfArrays.c @ 12:abf2117d7535
make lists clearable
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Fri, 31 Aug 2012 18:27:26 +0200 |
| parents | 5df9392eca1a |
| children |
line diff
1.1 --- a/ListOfArrays.c Tue Mar 13 18:31:06 2012 -0700 1.2 +++ b/ListOfArrays.c Fri Aug 31 18:27:26 2012 +0200 1.3 @@ -16,21 +16,24 @@ 1.4 void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr){ 1.5 int n; 1.6 uintptr_t p; 1.7 - int num_full = list->next_free_index / list->num_entries_per_fragment; //list->dim1info->numInArray -1 1.8 + int num_full = list->next_free_index / list->num_entries_per_fragment; //!\\ != list->dim1info->numInArray-1 1.9 for(n=0;n<num_full; n++){ 1.10 for(p = (uintptr_t) (list->dim1)[n]; p < (uintptr_t) (list->dim1)[n] + list->num_entries_per_fragment * list->entry_size; p += list->entry_size){ 1.11 (*fnPtr)((void*)p); 1.12 } 1.13 } 1.14 int offset_in_last = list->next_free_index % list->num_entries_per_fragment; 1.15 - n = list->dim1info->numInArray - 1; 1.16 - if (n >= 0){ 1.17 + if (n < list->dim1info->numInArray){ 1.18 for(p = (uintptr_t)(list->dim1)[n]; p < (uintptr_t)(list->dim1)[n] + offset_in_last * list->entry_size; p += list->entry_size){ 1.19 (*fnPtr)((void*)p); 1.20 } 1.21 } 1.22 } 1.23 1.24 +void clearListOfArrays(ListOfArrays* list){ 1.25 + list->next_free_index = 0; 1.26 +} 1.27 + 1.28 void freeListOfArrays(ListOfArrays* list){ 1.29 freeDynArrayDeep(list->dim1info,&VMS_int__free); 1.30 VMS_int__free((void*)list);
