src/server/config/mimeconf.c

changeset 91
fac51f87def0
parent 88
73b3485e96f1
child 97
09fbefc0e6a9
--- a/src/server/config/mimeconf.c	Wed Jul 31 13:02:06 2013 +0200
+++ b/src/server/config/mimeconf.c	Sun Sep 08 23:27:07 2013 +0200
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <ucx/mempool.h>
 #include "mimeconf.h"
 
 typedef struct {
@@ -49,7 +50,6 @@
     conf->directives = NULL;
     conf->ntypes = 0;
     int r = cfg_parse_basic_file((ConfigParser*)conf, in);
-    cfg_list_destr(conf->parser.mp, conf->directives);
     if(r != 0) {
         // TODO: free
         return NULL;
@@ -61,19 +61,19 @@
 }
 
 void free_mime_config(MimeConfig *conf) {
-    ucx_mempool_destroy(conf->parser.mp);
+    ucx_mempool_destroy(conf->parser.mp->pool);
     free(conf);
 }
 
 int mimeconf_parse(void *p, ConfigLine *begin, ConfigLine *end, sstr_t line) {
     MimeConfig *conf = p;
-    UcxMempool *mp = conf->parser.mp;
+    UcxAllocator *mp = conf->parser.mp;
     
     // parse mime directive
-    MimeDirective *dir = ucx_mempool_calloc(mp, 1, sizeof(MimeDirective));
+    MimeDirective *dir = OBJ_NEW_N(mp, MimeDirective);
     
     UcxList *params = cfg_param_list(line, mp);
-    UCX_FOREACH(UcxList*, params, pl) {
+    UCX_FOREACH(pl, params) {
         ConfigParam *param = pl->data;
         
         if(!sstrcmp(param->name, sstr("type"))) {
@@ -84,16 +84,15 @@
             size_t nx = 0;
             sstr_t *exts = sstrsplit(param->value, sstrn(",", 1), &nx);
             for(int i=0;i<nx;i++) {
-                sstr_t extstr = sstrdup_mp(mp, exts[i]);
-                dir->exts = ucx_list_append(dir->exts, extstr.ptr);
+                sstr_t extstr = sstrdup_a(mp, exts[i]);
+                dir->exts = ucx_list_append_a(mp, dir->exts, extstr.ptr);
                 free(exts[i].ptr);
             }
             free(exts);
         }
     }
     
-    cfg_list_destr(mp, dir->exts);
-    conf->directives = ucx_list_append(conf->directives, dir);
+    conf->directives = ucx_list_append_a(mp, conf->directives, dir);
     conf->ntypes++;
 
     return 0;

mercurial