added some allocation functions

Thu, 15 May 2014 17:17:58 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 15 May 2014 17:17:58 +0200
changeset 38
8ccdde37275b
parent 37
56016468753d
child 39
4e66271541e8

added some allocation functions

ui/common/context.c file | annotate | diff | comparison | revisions
ui/common/document.h file | annotate | diff | comparison | revisions
ui/ui/toolkit.h file | annotate | diff | comparison | revisions
--- a/ui/common/context.c	Thu May 15 15:53:29 2014 +0200
+++ b/ui/common/context.c	Thu May 15 17:17:58 2014 +0200
@@ -351,3 +351,21 @@
             ctx->group_widgets,
             gw);
 }
+
+void* ui_malloc(UiContext *ctx, size_t size) {
+    return ctx ? ucx_mempool_malloc(ctx->mempool, size) : NULL;
+}
+
+void* ui_calloc(UiContext *ctx, size_t nelem, size_t elsize) {
+    return ctx ? ucx_mempool_calloc(ctx->mempool, nelem, elsize) : NULL;
+}
+
+void ui_free(UiContext *ctx, void *ptr) {
+    if(ctx) {
+        ucx_mempool_free(ctx->mempool, ptr);
+    }
+}
+
+void* ui_realloc(UiContext *ctx, void *ptr, size_t size) {
+    return ctx ? ucx_mempool_realloc(ctx->mempool, ptr, size) : NULL;
+}
\ No newline at end of file
--- a/ui/common/document.h	Thu May 15 15:53:29 2014 +0200
+++ b/ui/common/document.h	Thu May 15 17:17:58 2014 +0200
@@ -38,12 +38,6 @@
 
 void uic_docmgr_init();
 void uic_document_addvar(void *doc, char *name, int type, size_t vs);
-void uic_document_addvar_v(
-        UiContext *uidoc,
-        char *name,
-        UiVar *newvar,
-        int type,
-        size_t vs);
 
 
 
--- a/ui/ui/toolkit.h	Thu May 15 15:53:29 2014 +0200
+++ b/ui/ui/toolkit.h	Thu May 15 17:17:58 2014 +0200
@@ -220,6 +220,7 @@
 
 UiContext* ui_document_context(void *doc);
 
+// TODO: remove
 void* ui_document_malloc(void *doc, size_t size);
 void* ui_document_calloc(void *doc, size_t nelem, size_t elsize);
 void  ui_document_free(void *doc, void *ptr);
@@ -237,11 +238,16 @@
 // new:
 int ui_getint(UiObject *obj, char *name);
 
-    
+
 void ui_set_group(UiContext *ctx, int group);
 void ui_unset_group(UiContext *ctx, int group);
 int* ui_active_groups(UiContext *ctx, int *ngroups);
     
+void* ui_malloc(UiContext *ctx, size_t size);
+void* ui_calloc(UiContext *ctx, size_t nelem, size_t elsize);
+void  ui_free(UiContext *ctx, void *ptr);
+void* ui_realloc(UiContext *ctx, void *ptr, size_t size);
+
 // types
 UiObserver* ui_observer_new(ui_callback f, void *data);
 UiObserver* ui_obsvlist_add(UiObserver *list, UiObserver *observer);

mercurial