| 620 |
620 |
| 621 void* ui_realloc(UiContext *ctx, void *ptr, size_t size) { |
621 void* ui_realloc(UiContext *ctx, void *ptr, size_t size) { |
| 622 return ctx ? cxRealloc(ctx->allocator, ptr, size) : NULL; |
622 return ctx ? cxRealloc(ctx->allocator, ptr, size) : NULL; |
| 623 } |
623 } |
| 624 |
624 |
| 625 UIEXPORT char* ui_strdup(UiContext *ctx, const char *str) { |
625 char* ui_strdup(UiContext *ctx, const char *str) { |
| 626 if(!ctx) { |
626 if(!ctx) { |
| 627 return NULL; |
627 return NULL; |
| 628 } |
628 } |
| 629 cxstring s = cx_str(str); |
629 cxstring s = cx_str(str); |
| 630 cxmutstr d = cx_strdup_a(ctx->allocator, s); |
630 cxmutstr d = cx_strdup_a(ctx->allocator, s); |
| 631 return d.ptr; |
631 return d.ptr; |
| 632 } |
632 } |
| |
633 |
| |
634 void ui_reg_destructor(UiContext *ctx, void *data, ui_destructor_func destr) { |
| |
635 cxMempoolRegister(ctx->mp, data, (cx_destructor_func)destr); |
| |
636 } |
| |
637 |
| |
638 void ui_set_destructor(void *mem, ui_destructor_func destr) { |
| |
639 cxMempoolSetDestructor(mem, (cx_destructor_func)destr); |
| |
640 } |