ui/common/context.c

changeset 52
0c881944fa10
parent 51
e324291ca9f8
equal deleted inserted replaced
51:e324291ca9f8 52:0c881944fa10
539 } 539 }
540 540
541 cxListAdd(ctx->group_widgets, &gw); 541 cxListAdd(ctx->group_widgets, &gw);
542 } 542 }
543 543
544 UIEXPORT void *ui_ctx_allocator(UiContext *ctx) { 544 UIEXPORT void *ui_allocator(UiContext *ctx) {
545 return (void*) ctx ? ctx->allocator : NULL; 545 return ctx ? (void*)ctx->allocator : NULL;
546 } 546 }
547 547
548 void* ui_malloc(UiContext *ctx, size_t size) { 548 void* ui_malloc(UiContext *ctx, size_t size) {
549 return ctx ? cxMalloc(ctx->allocator, size) : NULL; 549 return ctx ? cxMalloc(ctx->allocator, size) : NULL;
550 } 550 }
561 561
562 void* ui_realloc(UiContext *ctx, void *ptr, size_t size) { 562 void* ui_realloc(UiContext *ctx, void *ptr, size_t size) {
563 return ctx ? cxRealloc(ctx->allocator, ptr, size) : NULL; 563 return ctx ? cxRealloc(ctx->allocator, ptr, size) : NULL;
564 } 564 }
565 565
566 UIEXPORT char* ui_strdup(UiContext *ctx, const char *str) {
567 if(!ctx) {
568 return NULL;
569 }
570 cxstring s = cx_str(str);
571 cxmutstr d = cx_strdup_a(ctx->allocator, s);
572 return d.ptr;
573 }

mercurial