changeset 3:9c577efe70cd

added random access and free
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Wed, 21 Dec 2011 14:28:51 +0100
parents ef1712d6d7d8
children 53df05eb8d43
files ListOfArrays.c ListOfArrays.h
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/ListOfArrays.c	Tue Dec 20 18:52:57 2011 +0100
     1.2 +++ b/ListOfArrays.c	Wed Dec 21 14:28:51 2011 +0100
     1.3 @@ -5,8 +5,7 @@
     1.4  ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block){
     1.5      ListOfArrays* newLoA = (ListOfArrays*) VMS__malloc(sizeof(ListOfArrays));
     1.6      newLoA->dim1info = makePrivDynArrayOfSize(&(newLoA->dim1),8);
     1.7 -    
     1.8 -    
     1.9 +       
    1.10      newLoA->entry_size = entry_size;
    1.11      newLoA->num_entries_per_fragment = num_entries_per_block;
    1.12      newLoA->next_free_index = 0;
    1.13 @@ -31,6 +30,11 @@
    1.14      }
    1.15  }
    1.16  
    1.17 +void freeListOfArrays(ListOfArrays* list){
    1.18 +    freeDynArrayDeep(list->dim1info,&VMS__free);
    1.19 +    VMS__free((void*)list);
    1.20 +}
    1.21 +
    1.22  /*
    1.23  void addToListOfArraysDependency(Dependency value, ListOfArrays* list){
    1.24      int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; 
     2.1 --- a/ListOfArrays.h	Tue Dec 20 18:52:57 2011 +0100
     2.2 +++ b/ListOfArrays.h	Wed Dec 21 14:28:51 2011 +0100
     2.3 @@ -47,9 +47,9 @@
     2.4  
     2.5  void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr);
     2.6  
     2.7 -#define getValuefromListOfArrays(type,index,list)
     2.8 +#define valueInListOfArrays(type,index,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment]
     2.9  
    2.10 -#define setValueInListOfArrays(type,index,value,list)
    2.11 +#define setValueInListOfArrays(type,index,value,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment] = value
    2.12  
    2.13  #endif	/* LISTOFARRAYS_H */
    2.14