Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > ListOfArrays
comparison ListOfArrays.c @ 5:79982974d355
fix bug when last fragment exactly full
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Thu, 08 Mar 2012 19:05:26 +0100 |
| parents | 9c577efe70cd |
| children | 94a5b324bc29 |
comparison
equal
deleted
inserted
replaced
| 3:ab4ce76026da | 4:798984e6ff78 |
|---|---|
| 1 | 1 |
| 2 #include "ListOfArrays.h" | 2 #include "ListOfArrays.h" |
| 3 #include "../vmalloc.h" | 3 #include "../../VMS_Implementations/VMS_impl/vmalloc.h" |
| 4 | 4 |
| 5 ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block){ | 5 ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block){ |
| 6 ListOfArrays* newLoA = (ListOfArrays*) VMS__malloc(sizeof(ListOfArrays)); | 6 ListOfArrays* newLoA = (ListOfArrays*) VMS__malloc(sizeof(ListOfArrays)); |
| 7 newLoA->dim1info = makePrivDynArrayOfSize(&(newLoA->dim1),8); | 7 newLoA->dim1info = makePrivDynArrayOfSize(&(newLoA->dim1),8); |
| 8 | 8 |
| 14 } | 14 } |
| 15 | 15 |
| 16 void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr){ | 16 void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr){ |
| 17 int n; | 17 int n; |
| 18 uintptr_t p; | 18 uintptr_t p; |
| 19 for(n=0;n<list->dim1info->numInArray -1; n++){ | 19 int num_full = list->next_free_index / list->num_entries_per_fragment; //list->dim1info->numInArray -1 |
| 20 for(n=0;n<num_full; n++){ | |
| 20 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){ | 21 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){ |
| 21 (*fnPtr)((void*)p); | 22 (*fnPtr)((void*)p); |
| 22 } | 23 } |
| 23 } | 24 } |
| 24 int offset_in_last = list->next_free_index % list->num_entries_per_fragment; | 25 int offset_in_last = list->next_free_index % list->num_entries_per_fragment; |
