Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > ListOfArrays
comparison ListOfArrays.h @ 16:7731a4d31baa
new branch -- Univ_dev -- changed headers and PR__malloc
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Tue, 23 Jul 2013 07:30:42 -0700 |
| parents | 70c43c8fbded |
| children |
comparison
equal
deleted
inserted
replaced
| 10:c683d62b08c1 | 11:81685a907912 |
|---|---|
| 7 | 7 |
| 8 #ifndef _LISTOFARRAYS_H | 8 #ifndef _LISTOFARRAYS_H |
| 9 #define _LISTOFARRAYS_H | 9 #define _LISTOFARRAYS_H |
| 10 | 10 |
| 11 #include<stddef.h> | 11 #include<stddef.h> |
| 12 #include <inttypes.h> | |
| 13 | |
| 14 #include "PR__common_includes/PR__primitive_data_types.h" | |
| 12 #include "DynArray/DynArray.h" | 15 #include "DynArray/DynArray.h" |
| 13 | 16 |
| 14 | 17 |
| 15 typedef struct { | 18 typedef struct { |
| 16 void* next; | 19 void* next; |
| 29 ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block); | 32 ListOfArrays* makeListOfArrays(size_t entry_size, int num_entries_per_block); |
| 30 | 33 |
| 31 #define addToListOfArrays(type,value,list) do { \ | 34 #define addToListOfArrays(type,value,list) do { \ |
| 32 int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \ | 35 int offset_in_fragment = list->next_free_index % list->num_entries_per_fragment; \ |
| 33 if(offset_in_fragment == 0){ \ | 36 if(offset_in_fragment == 0){ \ |
| 34 void* newBlock = PR_int__malloc(list->entry_size * list->num_entries_per_fragment); \ | 37 void* newBlock = PR__malloc(list->entry_size * list->num_entries_per_fragment); \ |
| 35 addToDynArray(newBlock,list->dim1info); \ | 38 addToDynArray(newBlock,list->dim1info); \ |
| 36 } \ | 39 } \ |
| 37 type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \ | 40 type* typedFragment = (type*) ((list->dim1)[list->dim1info->numInArray -1]); \ |
| 38 typedFragment[offset_in_fragment] = value; \ | 41 typedFragment[offset_in_fragment] = value; \ |
| 39 list->next_free_index++; \ | 42 list->next_free_index++; \ |
