diff ListOfArrays.h @ 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 53df05eb8d43
children 0e6cc9d9ec67
line diff
     1.1 --- a/ListOfArrays.h	Wed Dec 21 16:55:02 2011 +0100
     1.2 +++ b/ListOfArrays.h	Thu Mar 08 19:05:26 2012 +0100
     1.3 @@ -39,6 +39,17 @@
     1.4      list->next_free_index++; \
     1.5  } while (0)
     1.6  
     1.7 +#define addToListOfArrays_ext(type,value,list) do { \
     1.8 +    int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \
     1.9 +    if(offset_in_fragment == 0){ \
    1.10 +        void* newBlock = malloc(list->entry_size * list->num_entries_per_fragment); \
    1.11 +        addToDynArray(newBlock,list->dim1info); \
    1.12 +    } \
    1.13 +    type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \
    1.14 +    typedFragment[offset_in_fragment] = value; \
    1.15 +    list->next_free_index++; \
    1.16 +} while (0)
    1.17 +
    1.18  typedef void  (*ListOfArraysFnPtr)  ( void * );  //fn has to cast void *
    1.19  
    1.20  void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr);