ui/common/context.c

changeset 52
0c881944fa10
parent 51
e324291ca9f8
--- a/ui/common/context.c	Sun Oct 20 21:24:13 2024 +0200
+++ b/ui/common/context.c	Mon Oct 21 11:14:26 2024 +0200
@@ -541,8 +541,8 @@
     cxListAdd(ctx->group_widgets, &gw);
 }
 
-UIEXPORT void *ui_ctx_allocator(UiContext *ctx) {
-    return (void*) ctx ? ctx->allocator : NULL;
+UIEXPORT void *ui_allocator(UiContext *ctx) {
+    return ctx ? (void*)ctx->allocator : NULL;
 }
 
 void* ui_malloc(UiContext *ctx, size_t size) {
@@ -563,3 +563,11 @@
     return ctx ? cxRealloc(ctx->allocator, ptr, size) : NULL;
 }
 
+UIEXPORT char* ui_strdup(UiContext *ctx, const char *str) {
+    if(!ctx) {
+        return NULL;
+    }
+    cxstring s = cx_str(str);
+    cxmutstr d = cx_strdup_a(ctx->allocator, s);
+    return d.ptr;
+}

mercurial