diff --git a/src/html.cc b/src/html.cc
index 8f11f4d..901284e 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -295,7 +295,7 @@ static void Html_set_link_coordinates(DilloHtml *html, int link, int x, int y)
if (x != -1) {
snprintf(data, 64, "?%d,%d", x, y);
- a_Url_set_ismap_coords(html->links->get(link), data);
+ a_Url_set_ismap_coords(html->links.at( link ).get(), data);
}
}
@@ -305,10 +305,9 @@ static void Html_set_link_coordinates(DilloHtml *html, int link, int x, int y)
*/
static int Html_set_new_link(DilloHtml *html, DilloUrl **url)
{
- int nl = html->links->size();
- html->links->increase();
- html->links->set(nl, (*url) ? *url : NULL);
- return nl;
+ html->links.emplace_back( (*url) ? *url : nullptr );
+
+ return html->links.size() - 1;
}
/**
@@ -507,7 +506,7 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
/* Init page-handling variables */
forms = new misc::SimpleVector (1);
inputs_outside_form = new misc::SimpleVector (1);
- links = new misc::SimpleVector (64);
+ links.reserve(64);
images = new misc::SimpleVector (16);
/* Initialize the main widget */
@@ -556,9 +555,12 @@ DilloHtml::~DilloHtml()
a_Html_input_delete(inputs_outside_form->get(i));
delete(inputs_outside_form);
- for (int i = 0; i < links->size(); i++)
- a_Url_free(links->get(i));
- delete (links);
+ for (auto &link: links)
+ // TODO: `DilloUrl` has to become RAII...
+ // TODO: In the interim, a `std::unique_ptr` deleter might
+ // be a good choice.
+ a_Url_free(link.release());
+ links.clear();
for (int i = 0; i < images->size(); i++) {
DilloHtmlImage *img = images->get(i);
@@ -749,7 +751,7 @@ bool DilloHtml::HtmlLinkReceiver::enter (Widget *widget, int link, int img,
} else {
_MSG(" Link ENTER notify...\n");
Html_set_link_coordinates(html, link, x, y);
- a_UIcmd_set_msg(bw, "%s", URL_STR(html->links->get(link)));
+ a_UIcmd_set_msg(bw, "%s", URL_STR(html->links.at(link).get()));
}
return true;
}
@@ -770,7 +772,7 @@ bool DilloHtml::HtmlLinkReceiver::press (Widget *widget, int link, int img,
if (img != -1) {
// image menu
if (link != -1)
- linkurl = html->links->get(link);
+ linkurl = html->links.at(link).get();
const bool_t loaded_img = (html->images->get(img)->image == NULL);
a_UIcmd_image_popup(bw, html->images->get(img)->url, loaded_img,
html->page_url, linkurl);
@@ -780,7 +782,7 @@ bool DilloHtml::HtmlLinkReceiver::press (Widget *widget, int link, int img,
a_UIcmd_page_popup(bw, bw->num_page_bugs != 0, html->cssUrls);
ret = true;
} else {
- a_UIcmd_link_popup(bw, html->links->get(link), html->page_url);
+ a_UIcmd_link_popup(bw, html->links.at(link).get(), html->page_url);
ret = true;
}
}
@@ -807,7 +809,7 @@ bool DilloHtml::HtmlLinkReceiver::click (Widget *widget, int link, int img,
}
if (link != -1) {
- DilloUrl *url = html->links->get(link);
+ DilloUrl *url = html->links.at(link).get();
_MSG("clicked on URL %d: %s\n", link, a_Url_str (url));
Html_set_link_coordinates(html, link, x, y);
diff --git a/src/html_common.hh b/src/html_common.hh
index 393268a..9a43e65 100644
--- a/src/html_common.hh
+++ b/src/html_common.hh
@@ -14,6 +14,9 @@
#ifndef __HTML_COMMON_HH__
#define __HTML_COMMON_HH__
+#include
+#include
+
#include "url.hh"
#include "bw.h"
@@ -212,7 +215,7 @@ public: //BUG: for now everything is public
/* -------------------------------------------------------------------*/
lout::misc::SimpleVector *forms;
lout::misc::SimpleVector *inputs_outside_form;
- lout::misc::SimpleVector *links;
+ std::vector< std::unique_ptr< DilloUrl > > links;
lout::misc::SimpleVector *images;
dw::ImageMapsList maps;