void style_free(style_t *style) { if(!style) return; printf("freeing style\n"); if(style->elemstyles) josm_elemstyles_free(style->elemstyles); g_free(style->name); g_free(style->icon.path_prefix); g_free(style); }
int main(int argc, char **argv) { OSM2GO_TEST_INIT(argc, argv); if (argc < 4 || argc > 5) { usage(argv[0]); return 1; } char *endp; unsigned long rules = strtoul(argv[2], &endp, 10); if (endp == nullptr || *endp != 0) { usage(argv[0]); return 1; } unsigned long conditions = strtoul(argv[3], &endp, 10); if (endp == nullptr || *endp != 0) { usage(argv[0]); return 1; } if(argc == 5) path_prefix = argv[4]; xmlInitParser(); std::vector<elemstyle_t *> styles = josm_elemstyles_load(argv[1]); if(styles.empty()) { std::cerr << "failed to load styles" << std::endl; return 1; } std::cout << styles.size() << " top level items found"; if (styles.size() != rules) { std::cout << ", but " << rules << " expected"; error = true; } std::cout << std::endl; std::for_each(styles.begin(), styles.end(), checkItem); if (counter.ruletypes.size() > 4) { std::cerr << "too many rule types found" << std::endl; error = true; } std::for_each(styles.begin(), styles.end(), icon_check); std::for_each(counter.ruletypes.begin(), counter.ruletypes.end(), show_rule_count); std::cout << counter.conditions << " conditions found"; if (counter.conditions != conditions) { std::cout << ", but " << conditions << " expected"; error = true; } std::cout << std::endl; josm_elemstyles_free(styles); xmlCleanupParser(); return error ? 1 : 0; }