--- a/src/server/plugins/postgresql/config.c Wed Nov 02 19:19:01 2022 +0100 +++ b/src/server/plugins/postgresql/config.c Sun Nov 06 15:53:32 2022 +0100 @@ -87,18 +87,18 @@ } PgRepository* pg_init_repo(ServerConfiguration *cfg, pool_handle_t *pool, WSConfigNode *config) { - UcxAllocator a = util_pool_allocator(pool); + CxAllocator *a = pool_allocator(pool); - ConfigNode *pg = serverconfig_get_node(config, CONFIG_NODE_OBJECT, SC("Postgresql")); + ConfigNode *pg = serverconfig_get_node(config, CONFIG_NODE_OBJECT, cx_str("Postgresql")); if(!pg) { log_ereport(LOG_MISCONFIG, "pg_init_repo: missing postgresql config object"); return NULL; } - scstr_t cfg_respool = serverconfig_directive_value(pg, SC("ResourcePool")); - scstr_t cfg_rootid = serverconfig_directive_value(pg, SC("RootId")); - scstr_t cfg_rootnode = serverconfig_directive_value(pg, SC("RootNode")); - scstr_t cfg_dav = serverconfig_directive_value(pg, SC("PGDavConfig")); + cxstring cfg_respool = serverconfig_directive_value(pg, cx_str("ResourcePool")); + cxstring cfg_rootid = serverconfig_directive_value(pg, cx_str("RootId")); + cxstring cfg_rootnode = serverconfig_directive_value(pg, cx_str("RootNode")); + cxstring cfg_dav = serverconfig_directive_value(pg, cx_str("PGDavConfig")); // minimum requirement is a resource pool if(cfg_respool.length == 0) { @@ -140,7 +140,7 @@ PgRepository *repo = pool_malloc(pool, sizeof(PgRepository)); ZERO(repo, sizeof(PgRepository)); - repo->resourcepool = sstrdup_a(&a, cfg_respool); + repo->resourcepool = cx_strdup_a(a, cfg_respool); repo->root_resource_id = root_id; // check for extended pg dav config @@ -188,7 +188,7 @@ PgRepository *repo, const char *file_path) { - UcxAllocator a = util_pool_allocator(pool); + CxAllocator *a = pool_allocator(pool); // check if the file exists and can be accessed struct stat s; @@ -203,7 +203,7 @@ } // prepare PgRepository - repo->prop_ext = ucx_map_new_a(&a, 8); + repo->prop_ext = cxHashMapCreate(a, 8); if(!repo->prop_ext) { log_ereport(LOG_FAILURE, "pg: cannot load config file: OOM"); return 1; @@ -245,8 +245,8 @@ int ret = 0; PgExtParser parserData; - parserData.table_lookup = ucx_map_new(8); - parserData.tables = NULL; + parserData.table_lookup = cxHashMapCreate(cxDefaultAllocator, 8); + parserData.tables = cxLinkedListCreate(cxDefaultAllocator, cx_cmp_ptr, sizeof(PgExtTable)); while(node && !ret) { // currently, the only possible config element is <extension> @@ -260,13 +260,13 @@ // convert parserData if(!ret) { - size_t ntables = ucx_list_size(parserData.tables); + size_t ntables = parserData.tables->size; repo->ntables = ntables; repo->tables = pool_calloc(pool, ntables, sizeof(PgExtTable)); if(repo->tables) { int i = 0; - UCX_FOREACH(elm, parserData.tables) { - PgExtTable *tab = elm->data; + CxIterator iter = cxListIterator(parserData.tables, 0); + cx_foreach(PgExtTable *, tab, iter) { repo->tables[i++] = *tab; } } else { @@ -276,9 +276,8 @@ } // cleanup parser - ucx_list_free_content(parserData.tables, free); - ucx_list_free(parserData.tables); - ucx_map_free(parserData.table_lookup); + cxListDestroy(parserData.tables); + cxMapDestroy(parserData.table_lookup); return ret; } @@ -290,12 +289,12 @@ const char *file_path, xmlNode *ext_node) { - UcxAllocator a = util_pool_allocator(pool); + CxAllocator *a = pool_allocator(pool); xmlNode *node = ext_node->children; const char *table = NULL; - UcxList *properties = NULL; + CxList *properties = cxPointerLinkedListCreate(a, cx_cmp_ptr); while(node) { if(node->type == XML_ELEMENT_NODE) { @@ -325,7 +324,7 @@ log_ereport(LOG_MISCONFIG, "pg: config %s: no column specified for property %s", file_path, ps->name); return 1; } - properties = ucx_list_append_a(&a, properties, ps); + cxListAdd(properties, ps); } ps = ps->next; } @@ -345,7 +344,7 @@ } // check if the table was already specified - if(ucx_map_cstr_get(ext->table_lookup, table)) { + if(cxMapGet(ext->table_lookup, cx_hash_key_str(table))) { log_ereport(LOG_MISCONFIG, "pg: config %s: extension table %s not unique", file_path, table); return 1; } @@ -355,19 +354,18 @@ if(!tabname) return 1; // exttable is only used temporarily - PgExtTable *exttable = malloc(sizeof(PgExtTable)); - if(!exttable) return 1; - exttable->table = tabname; - exttable->isused = 0; // not relevant in config - int tableindex = (int)ucx_list_size(ext->tables); - ext->tables = ucx_list_append(ext->tables, exttable); + PgExtTable exttable; + exttable.table = tabname; + exttable.isused = 0; // not relevant in config + int tableindex = (int)ext->tables->size; + cxListAdd(ext->tables, &exttable); - if(ucx_map_cstr_put(ext->table_lookup, table, table)) { + if(cxMapPut(ext->table_lookup, cx_hash_key_str(table), (void*)table)) { return 1; } - UCX_FOREACH(elm, properties) { - xmlNode *ps = elm->data; + CxIterator iter = cxListIterator(properties, 0); + cx_foreach(xmlNode *, ps, iter) { const char *value = pg_util_xml_get_text(ps); PgPropertyStoreExt *ext_col = pool_malloc(pool, sizeof(PgPropertyStoreExt)); @@ -382,9 +380,9 @@ return 1; } - UcxKey key = webdav_property_key(ext_col->ns, ext_col->name); - int err = ucx_map_put(repo->prop_ext, key, ext_col); - free((void*)key.data); + CxHashKey key = webdav_property_key(ext_col->ns, ext_col->name); + int err = cxMapPut(repo->prop_ext, key, ext_col); + free(key.data.bytes); if(err) { return 1; }