changeset 17:6386ae5cc770 Univ_dev

Updated include paths
author Sean Halle <seanhalle@yahoo.com>
date Fri, 20 Sep 2013 00:02:12 -0700
parents 7731a4d31baa
children db10d06ca4ad
files ListOfArrays.c ListOfArrays.h prlistofarrays.h
diffstat 3 files changed, 69 insertions(+), 69 deletions(-) [+]
line diff
     1.1 --- a/ListOfArrays.c	Tue Jul 23 07:30:42 2013 -0700
     1.2 +++ b/ListOfArrays.c	Fri Sep 20 00:02:12 2013 -0700
     1.3 @@ -1,6 +1,6 @@
     1.4  
     1.5 -#include "ListOfArrays.h"
     1.6 -#include "PR__common_includes/Services_Offered_by_PR/Memory_Handling/vmalloc__wrapper_library.h"
     1.7 +#include <PR__include/prlistofarrays.h>
     1.8 +#include <PR__include/prmalloc.h>
     1.9  
    1.10  ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block){
    1.11      ListOfArrays* newLoA = (ListOfArrays*) PR__malloc(sizeof(ListOfArrays));
     2.1 --- a/ListOfArrays.h	Tue Jul 23 07:30:42 2013 -0700
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,67 +0,0 @@
     2.4 -/* 
     2.5 - * File:   ListOfArrays.h
     2.6 - * Author: Nina Engelhardt
     2.7 - *
     2.8 - * Created on December 16, 2011, 2:06 PM
     2.9 - */
    2.10 -
    2.11 -#ifndef  _LISTOFARRAYS_H
    2.12 -#define	_LISTOFARRAYS_H
    2.13 -
    2.14 -#include<stddef.h>
    2.15 -#include <inttypes.h>
    2.16 -
    2.17 -#include "PR__common_includes/PR__primitive_data_types.h"
    2.18 -#include "DynArray/DynArray.h"
    2.19 -
    2.20 -
    2.21 -typedef struct {
    2.22 -    void* next;
    2.23 -    void* data;
    2.24 -} ArrayFragment;
    2.25 -
    2.26 -typedef struct {
    2.27 -    void** dim1;
    2.28 -    PrivDynArrayInfo* dim1info;
    2.29 -    //ArrayFragment* last;
    2.30 -    size_t entry_size;
    2.31 -    int num_entries_per_fragment;
    2.32 -    int next_free_index;
    2.33 -} ListOfArrays;
    2.34 -
    2.35 -ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block);
    2.36 -
    2.37 -#define addToListOfArrays(type,value,list) do { \
    2.38 -    int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \
    2.39 -    if(offset_in_fragment == 0){ \
    2.40 -        void* newBlock = PR__malloc(list->entry_size * list->num_entries_per_fragment); \
    2.41 -        addToDynArray(newBlock,list->dim1info); \
    2.42 -    } \
    2.43 -    type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \
    2.44 -    typedFragment[offset_in_fragment] = value; \
    2.45 -    list->next_free_index++; \
    2.46 -} while (0)
    2.47 -
    2.48 -#define addToListOfArrays_ext(type,value,list) do { \
    2.49 -    int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \
    2.50 -    if(offset_in_fragment == 0){ \
    2.51 -        void* newBlock = malloc(list->entry_size * list->num_entries_per_fragment); \
    2.52 -        addToDynArray(newBlock,list->dim1info); \
    2.53 -    } \
    2.54 -    type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \
    2.55 -    typedFragment[offset_in_fragment] = value; \
    2.56 -    list->next_free_index++; \
    2.57 -} while (0)
    2.58 -
    2.59 -typedef void  (*ListOfArraysFnPtr)  ( void * );  //fn has to cast void *
    2.60 -
    2.61 -void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr);
    2.62 -
    2.63 -#define valueInListOfArrays(type,index,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment]
    2.64 -
    2.65 -#define setValueInListOfArrays(type,index,value,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment] = value
    2.66 -
    2.67 -void freeListOfArrays(ListOfArrays* list);
    2.68 -
    2.69 -#endif	/* LISTOFARRAYS_H */
    2.70 -
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/prlistofarrays.h	Fri Sep 20 00:02:12 2013 -0700
     3.3 @@ -0,0 +1,67 @@
     3.4 +/* 
     3.5 + * File:   ListOfArrays.h
     3.6 + * Author: Nina Engelhardt
     3.7 + *
     3.8 + * Created on December 16, 2011, 2:06 PM
     3.9 + */
    3.10 +
    3.11 +#ifndef  _LISTOFARRAYS_H
    3.12 +#define	_LISTOFARRAYS_H
    3.13 +
    3.14 +#include<stddef.h>
    3.15 +#include <inttypes.h>
    3.16 +
    3.17 +#include <PR__include/PR__primitive_data_types.h>
    3.18 +#include <PR__include/prdynarray.h>
    3.19 +
    3.20 +
    3.21 +typedef struct {
    3.22 +    void* next;
    3.23 +    void* data;
    3.24 +} ArrayFragment;
    3.25 +
    3.26 +typedef struct {
    3.27 +    void** dim1;
    3.28 +    PrivDynArrayInfo* dim1info;
    3.29 +    //ArrayFragment* last;
    3.30 +    size_t entry_size;
    3.31 +    int num_entries_per_fragment;
    3.32 +    int next_free_index;
    3.33 +} ListOfArrays;
    3.34 +
    3.35 +ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block);
    3.36 +
    3.37 +#define addToListOfArrays(type,value,list) do { \
    3.38 +    int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \
    3.39 +    if(offset_in_fragment == 0){ \
    3.40 +        void* newBlock = PR__malloc(list->entry_size * list->num_entries_per_fragment); \
    3.41 +        addToDynArray(newBlock,list->dim1info); \
    3.42 +    } \
    3.43 +    type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \
    3.44 +    typedFragment[offset_in_fragment] = value; \
    3.45 +    list->next_free_index++; \
    3.46 +} while (0)
    3.47 +
    3.48 +#define addToListOfArrays_ext(type,value,list) do { \
    3.49 +    int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \
    3.50 +    if(offset_in_fragment == 0){ \
    3.51 +        void* newBlock = malloc(list->entry_size * list->num_entries_per_fragment); \
    3.52 +        addToDynArray(newBlock,list->dim1info); \
    3.53 +    } \
    3.54 +    type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \
    3.55 +    typedFragment[offset_in_fragment] = value; \
    3.56 +    list->next_free_index++; \
    3.57 +} while (0)
    3.58 +
    3.59 +typedef void  (*ListOfArraysFnPtr)  ( void * );  //fn has to cast void *
    3.60 +
    3.61 +void forAllInListOfArraysDo(ListOfArrays* list, ListOfArraysFnPtr fnPtr);
    3.62 +
    3.63 +#define valueInListOfArrays(type,index,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment]
    3.64 +
    3.65 +#define setValueInListOfArrays(type,index,value,list) ((type*)((list->dim1)[index / list->num_entries_per_fragment]))[index % list->num_entries_per_fragment] = value
    3.66 +
    3.67 +void freeListOfArrays(ListOfArrays* list);
    3.68 +
    3.69 +#endif	/* LISTOFARRAYS_H */
    3.70 +