229 |
229 |
230 newmodel->titles = cxCalloc(a, model->columns, sizeof(char*)); |
230 newmodel->titles = cxCalloc(a, model->columns, sizeof(char*)); |
231 for (int i = 0; i < model->columns; i++) { |
231 for (int i = 0; i < model->columns; i++) { |
232 newmodel->titles[i] = model->titles[i] ? cx_strdup_a(a, cx_str(model->titles[i])).ptr : NULL; |
232 newmodel->titles[i] = model->titles[i] ? cx_strdup_a(a, cx_str(model->titles[i])).ptr : NULL; |
233 } |
233 } |
|
234 newmodel->columnsize = cxCalloc(a, model->columns, sizeof(int)); |
|
235 memcpy(newmodel->columnsize, model->columnsize, model->columns*sizeof(int)); |
234 |
236 |
235 return newmodel; |
237 return newmodel; |
236 } |
238 } |
237 |
239 |
238 void ui_model_free(UiContext *ctx, UiModel *mi) { |
240 void ui_model_free(UiContext *ctx, UiModel *mi) { |
239 const CxAllocator* a = ctx ? ctx->allocator : cxDefaultAllocator; |
241 const CxAllocator* a = ctx ? ctx->allocator : cxDefaultAllocator; |
240 cxFree(a, mi->types); |
242 cxFree(a, mi->types); |
241 cxFree(a, mi->titles); |
243 cxFree(a, mi->titles); |
|
244 cxFree(a, mi->columnsize); |
242 cxFree(a, mi); |
245 cxFree(a, mi); |
243 } |
246 } |
244 |
247 |
245 // types |
248 // types |
246 |
249 |