113 |
113 |
114 void process_parts(xmlTextReaderPtr reader, LocalResource *res) { |
114 void process_parts(xmlTextReaderPtr reader, LocalResource *res) { |
115 // TODO: rewrite using low level array |
115 // TODO: rewrite using low level array |
116 |
116 |
117 CxList *parts = cxLinkedListCreateSimple(CX_STORE_POINTERS); |
117 CxList *parts = cxLinkedListCreateSimple(CX_STORE_POINTERS); |
118 cxDefineDestructor(parts, filepart_free); |
|
119 |
118 |
120 FilePart *current_part = NULL; |
119 FilePart *current_part = NULL; |
121 |
120 |
122 size_t count = 0; |
121 size_t count = 0; |
123 int field = -1; |
122 int field = -1; |
164 } |
163 } |
165 } |
164 } |
166 |
165 |
167 if(!err) { |
166 if(!err) { |
168 FilePart *file_parts = calloc(count, sizeof(FilePart)); |
167 FilePart *file_parts = calloc(count, sizeof(FilePart)); |
169 size_t i = 0; |
|
170 CxIterator iter = cxListIterator(parts); |
168 CxIterator iter = cxListIterator(parts); |
171 cx_foreach(FilePart*, p, iter) { |
169 cx_foreach(FilePart*, p, iter) { |
172 file_parts[i] = *p; |
170 file_parts[iter.index] = *p; |
173 free(p); |
171 free(p); |
174 i++; |
|
175 } |
172 } |
176 |
173 |
177 res->parts = file_parts; |
174 res->parts = file_parts; |
178 res->numparts = count; |
175 res->numparts = count; |
179 } |
176 } |