Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > ListOfArrays
diff ListOfArrays.h @ 2:ef1712d6d7d8
change internal structure from list to dynarray
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Tue, 20 Dec 2011 18:52:57 +0100 |
| parents | fd441e4d0908 |
| children | 9c577efe70cd |
line diff
1.1 --- a/ListOfArrays.h Mon Dec 19 17:11:22 2011 +0100 1.2 +++ b/ListOfArrays.h Tue Dec 20 18:52:57 2011 +0100 1.3 @@ -9,6 +9,9 @@ 1.4 #define LISTOFARRAYS_H 1.5 1.6 #include<stddef.h> 1.7 +#include "../DynArray/DynArray.h" 1.8 +#include "../../dependency.h" 1.9 + 1.10 1.11 typedef struct { 1.12 void* next; 1.13 @@ -16,8 +19,9 @@ 1.14 } ArrayFragment; 1.15 1.16 typedef struct { 1.17 - ArrayFragment* first; 1.18 - ArrayFragment* last; 1.19 + void** dim1; 1.20 + PrivDynArrayInfo* dim1info; 1.21 + //ArrayFragment* last; 1.22 size_t entry_size; 1.23 int num_entries_per_fragment; 1.24 int next_free_index; 1.25 @@ -28,21 +32,17 @@ 1.26 #define addToListOfArrays(type,value,list) do { \ 1.27 int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \ 1.28 if(offset_in_fragment == 0){ \ 1.29 - ArrayFragment* newBlock = (ArrayFragment*) VMS__malloc(sizeof(ArrayFragment*) + list->entry_size * list->num_entries_per_fragment); \ 1.30 - newBlock->next == NULL; \ 1.31 - if(list->first == NULL) {\ 1.32 - list->first = newBlock; \ 1.33 - } \ 1.34 - if(list->last != NULL) { \ 1.35 - list->last->next = newBlock; \ 1.36 - } \ 1.37 - list->last = newBlock; \ 1.38 + void* newBlock = VMS__malloc(list->entry_size * list->num_entries_per_fragment); \ 1.39 + addToDynArray(newBlock,list->dim1info); \ 1.40 } \ 1.41 - type* typedFragment = (type*) &(list->last->data); \ 1.42 + type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \ 1.43 typedFragment[offset_in_fragment] = value; \ 1.44 list->next_free_index++; \ 1.45 } while (0) 1.46 1.47 +//void addToListOfArraysDependency(Dependency value, ListOfArrays* list); 1.48 +//void addToListOfArraysUnit(Unit value, ListOfArrays* list); 1.49 + 1.50 typedef void (*ListOfArraysFnPtr) ( void * ); //fn has to cast void * 1.51 1.52 void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr);
