131 // create a buffer using the memory pool for destruction |
126 // create a buffer using the memory pool for destruction |
132 CxBuffer *content = cxBufferCreate(NULL, 256, pool->allocator, CX_BUFFER_AUTO_EXTEND); |
127 CxBuffer *content = cxBufferCreate(NULL, 256, pool->allocator, CX_BUFFER_AUTO_EXTEND); |
133 |
128 |
134 // read the file into the buffer and turn it into a string |
129 // read the file into the buffer and turn it into a string |
135 cx_stream_copy(f, content, (cx_read_func) fread, (cx_write_func) cxBufferWrite); |
130 cx_stream_copy(f, content, (cx_read_func) fread, (cx_write_func) cxBufferWrite); |
|
131 fclose(f); |
136 cxstring contentstr = cx_strn(content->space, content->size); |
132 cxstring contentstr = cx_strn(content->space, content->size); |
137 |
133 |
138 // split the string into lines - use the mempool for allocating the target array |
134 // split the string into lines - use the mempool for allocating the target array |
139 cxstring* lines; |
135 cxstring* lines; |
140 size_t lc = cx_strsplit_a(pool->allocator, contentstr, |
136 size_t lc = cx_strsplit_a(pool->allocator, contentstr, |
233 struct cx_list_s { |
229 struct cx_list_s { |
234 CX_COLLECTION_MEMBERS // size, capacity, etc. |
230 CX_COLLECTION_MEMBERS // size, capacity, etc. |
235 cx_list_class const *cl; // The list class definition |
231 cx_list_class const *cl; // The list class definition |
236 }; |
232 }; |
237 ``` |
233 ``` |
238 The actual structure contains one more class pointer that is used when wrapping a list into a pointer aware list |
234 The actual structure contains one more class pointer that is used when wrapping a list into a pointer-aware list |
239 with `cxListStorePointers()`. What this means, is that - if you want to implement your own list structure - you |
235 with `cxListStorePointers()`. What this means, is that - if you want to implement your own list structure - you |
240 only need to cover the case where the list is storing copies of your objects. |
236 only need to cover the case where the list is storing copies of your objects. |
241 |
237 |
242 UCX comes with two common list implementations (linked list and array list) that should cover most use cases. |
238 UCX comes with two common list implementations (linked list and array list) that should cover most use cases. |
243 But if you feel the need to implement an own list, the only thing you need to do is to define a struct where |
239 But if you feel the need to implement an own list, the only thing you need to do is to define a struct where |