src/server/config/objconf.c

changeset 579
e10457d74fe1
parent 576
5c31cc844c68
equal deleted inserted replaced
578:eb48f716b31c 579:e10457d74fe1
41 * object 41 * object
42 */ 42 */
43 43
44 44
45 ObjectConfig2* objectconf_load(const char *file) { 45 ObjectConfig2* objectconf_load(const char *file) {
46 CxMempool *mp = cxBasicMempoolCreate(512); 46 CxMempool *mp = cxMempoolCreateSimple(512);
47 if(!mp) { 47 if(!mp) {
48 return NULL; 48 return NULL;
49 } 49 }
50 50
51 // setup parser 51 // setup parser
59 parser.validateObjEnd = objectconf_validate_objend; 59 parser.validateObjEnd = objectconf_validate_objend;
60 parser.allow_hierarchy = 1; 60 parser.allow_hierarchy = 1;
61 61
62 ConfigNode *obj_config = serverconfig_load_file(&parser, file); 62 ConfigNode *obj_config = serverconfig_load_file(&parser, file);
63 if(!obj_config) { 63 if(!obj_config) {
64 cxMempoolDestroy(mp); 64 cxMempoolFree(mp);
65 return NULL; 65 return NULL;
66 } 66 }
67 67
68 ObjectConfig2 *conf = cxMalloc(mp->allocator, sizeof(ObjectConfig2)); 68 ObjectConfig2 *conf = cxMalloc(mp->allocator, sizeof(ObjectConfig2));
69 if(!conf) { 69 if(!conf) {
70 cxMempoolDestroy(mp); 70 cxMempoolFree(mp);
71 return NULL; 71 return NULL;
72 } 72 }
73 73
74 conf->mp = mp; 74 conf->mp = mp;
75 conf->root = obj_config; 75 conf->root = obj_config;
76 76
77 return conf; 77 return conf;
78 } 78 }
79 79
80 void objectconf_free(ObjectConfig2 *objconf) { 80 void objectconf_free(ObjectConfig2 *objconf) {
81 cxMempoolDestroy(objconf->mp); 81 cxMempoolFree(objconf->mp);
82 } 82 }
83 83
84 int objectconf_validate_directive(ConfigParser2 *parser, ConfigNode *node) { 84 int objectconf_validate_directive(ConfigParser2 *parser, ConfigNode *node) {
85 // It is possible that this function is called for Objects 85 // It is possible that this function is called for Objects
86 // if { is on the next line 86 // if { is on the next line

mercurial