diff --git a/src/html.cc b/src/html.cc index aa47728..fb64a1f 100644 --- a/src/html.cc +++ b/src/html.cc @@ -2307,20 +2307,19 @@ static void Html_tag_close_map(DilloHtml *html) /** * Read coords in a string, returning a vector of ints. */ -static -misc::SimpleVector *Html_read_coords(DilloHtml *html, const char *str) +static std::vector< int > +Html_read_coords(DilloHtml *html, const char *str) { int coord; const char *tail = str; char *newtail = NULL; - misc::SimpleVector *coords = new misc::SimpleVector (4); + std::vector< int > coords; while (1) { coord = strtol(tail, &newtail, 10); if (coord == 0 && newtail == tail) break; - coords->increase(); - coords->set(coords->size() - 1, coord); + coords.push_back( coord ); while (isspace(*newtail)) newtail++; if (!*newtail) @@ -2342,7 +2341,6 @@ static void { enum types {UNKNOWN, RECTANGLE, CIRCLE, POLYGON, BACKGROUND}; types type; - misc::SimpleVector *coords = NULL; DilloUrl* url; const char *attrbuf; int link = -1; @@ -2370,33 +2368,32 @@ static void } if (type == RECTANGLE || type == CIRCLE || type == POLYGON) { if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "coords"))) { - coords = Html_read_coords(html, attrbuf); + auto coords= Html_read_coords(html, attrbuf); if (type == RECTANGLE) { - if (coords->size() != 4) + if (coords.size() != 4) BUG_MSG(" rectangle must have four coordinate values."); - if (coords->size() >= 4) - shape = std::make_unique< Rectangle >(coords->get(0), - coords->get(1), - coords->get(2) - coords->get(0), - coords->get(3) - coords->get(1)); + if (coords.size() >= 4) + shape = std::make_unique< Rectangle >(coords.at(0), + coords.at(1), + coords.at(2) - coords.at(0), + coords.at(3) - coords.at(1)); } else if (type == CIRCLE) { - if (coords->size() != 3) + if (coords.size() != 3) BUG_MSG(" circle must have three coordinate values."); - if (coords->size() >= 3) - shape = std::make_unique< Circle >(coords->get(0), coords->get(1), - coords->get(2)); + if (coords.size() >= 3) + shape = std::make_unique< Circle >(coords.at(0), coords.at(1), + coords.at(2)); } else if (type == POLYGON) { std::unique_ptr< Polygon > poly; int i; - if (coords->size() % 2) + if (coords.size() % 2) BUG_MSG(" polygon with odd number of coordinates."); poly = std::make_unique< Polygon >(); - for (i = 0; i < (coords->size() / 2); i++) - poly->addPoint(coords->get(2*i), coords->get(2*i + 1)); + for (i = 0; i < (coords.size() / 2); i++) + poly->addPoint(coords.at(2*i), coords.at(2*i + 1)); shape= std::move( poly ); } - delete(coords); } } if (shape != nullptr || type == BACKGROUND) {