ui/common/document.c

branch
newapi
changeset 398
4d87a137fe70
parent 379
958bae372271
equal deleted inserted replaced
397:6d4adf6fba1f 398:4d87a137fe70
84 84
85 void* ui_document_new(size_t size) { 85 void* ui_document_new(size_t size) {
86 CxMempool *mp = cxMempoolCreate(256, NULL); 86 CxMempool *mp = cxMempoolCreate(256, NULL);
87 const CxAllocator *a = mp->allocator; 87 const CxAllocator *a = mp->allocator;
88 UiContext *ctx = cxCalloc(a, 1, sizeof(UiContext)); 88 UiContext *ctx = cxCalloc(a, 1, sizeof(UiContext));
89 ctx->mp = mp;
89 ctx->attach_document = uic_context_attach_document; 90 ctx->attach_document = uic_context_attach_document;
90 ctx->detach_document2 = uic_context_detach_document2; 91 ctx->detach_document2 = uic_context_detach_document2;
91 ctx->allocator = a; 92 ctx->allocator = a;
92 ctx->vars = cxHashMapCreate(a, CX_STORE_POINTERS, 16); 93 ctx->vars = cxHashMapCreate(a, CX_STORE_POINTERS, 16);
93 94
94 void *document = cxCalloc(a, 1, size); 95 void *document = cxCalloc(a, size, 1);
95 cxMapPut(documents, cx_hash_key(&document, sizeof(void*)), ctx); 96 cxMapPut(documents, cx_hash_key(&document, sizeof(void*)), ctx);
96 return document; 97 return document;
97 } 98 }
98 99
99 void ui_document_destroy(void *doc) { 100 void ui_document_destroy(void *doc) {

mercurial