ui/common/document.c

changeset 3
f154867f54dc
parent 0
2483f517c562
child 54
3ca3acefc66a
equal deleted inserted replaced
2:fbdfaacc4182 3:f154867f54dc
36 #include <cx/mempool.h> 36 #include <cx/mempool.h>
37 37
38 static CxMap *documents; 38 static CxMap *documents;
39 39
40 void uic_docmgr_init() { 40 void uic_docmgr_init() {
41 documents = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 32); 41 if (!documents) {
42 documents = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 32);
43 }
42 } 44 }
43 45
44 void ui_set_document(UiObject *obj, void *document) { 46 void ui_set_document(UiObject *obj, void *document) {
45 uic_context_detach_all(obj->ctx); 47 uic_context_detach_all(obj->ctx);
46 obj->ctx->attach_document(obj->ctx, document); 48 obj->ctx->attach_document(obj->ctx, document);
78 // TODO 80 // TODO
79 return NULL; 81 return NULL;
80 } 82 }
81 83
82 void* ui_document_new(size_t size) { 84 void* ui_document_new(size_t size) {
83 CxMempool *mp = cxBasicMempoolCreate(256); 85 CxMempool *mp = cxMempoolCreate(256, NULL);
84 const CxAllocator *a = mp->allocator; 86 const CxAllocator *a = mp->allocator;
85 UiContext *ctx = cxCalloc(a, 1, sizeof(UiContext)); 87 UiContext *ctx = cxCalloc(a, 1, sizeof(UiContext));
86 ctx->attach_document = uic_context_attach_document; 88 ctx->attach_document = uic_context_attach_document;
87 ctx->detach_document2 = uic_context_detach_document2; 89 ctx->detach_document2 = uic_context_detach_document2;
88 ctx->allocator = a; 90 ctx->allocator = a;

mercurial