Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > ListOfArrays
diff ListOfArrays.h @ 1:fd441e4d0908
bugfix
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Mon, 19 Dec 2011 17:11:22 +0100 |
| parents | bc4b3434367f |
| children | ef1712d6d7d8 |
line diff
1.1 --- a/ListOfArrays.h Mon Dec 19 13:25:30 2011 +0100 1.2 +++ b/ListOfArrays.h Mon Dec 19 17:11:22 2011 +0100 1.3 @@ -8,8 +8,10 @@ 1.4 #ifndef LISTOFARRAYS_H 1.5 #define LISTOFARRAYS_H 1.6 1.7 +#include<stddef.h> 1.8 + 1.9 typedef struct { 1.10 - ArrayFragment* next; 1.11 + void* next; 1.12 void* data; 1.13 } ArrayFragment; 1.14 1.15 @@ -21,6 +23,8 @@ 1.16 int next_free_index; 1.17 } ListOfArrays; 1.18 1.19 +ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block); 1.20 + 1.21 #define addToListOfArrays(type,value,list) do { \ 1.22 int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \ 1.23 if(offset_in_fragment == 0){ \ 1.24 @@ -34,11 +38,18 @@ 1.25 } \ 1.26 list->last = newBlock; \ 1.27 } \ 1.28 - (type*) typedFragment = (type*) list->last->data; \ 1.29 + type* typedFragment = (type*) &(list->last->data); \ 1.30 typedFragment[offset_in_fragment] = value; \ 1.31 + list->next_free_index++; \ 1.32 } while (0) 1.33 1.34 typedef void (*ListOfArraysFnPtr) ( void * ); //fn has to cast void * 1.35 1.36 +void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr); 1.37 + 1.38 +#define getValuefromListOfArrays(type,index,list) 1.39 + 1.40 +#define setValueInListOfArrays(type,index,value,list) 1.41 + 1.42 #endif /* LISTOFARRAYS_H */ 1.43
