DilloURL has a dtor.

It is the same as the original free function.  But this
will let me put some ownership on various members and slowly
start to C++ify this core type.
This commit is contained in:
2025-04-12 04:08:14 -04:00
parent 07485c7959
commit 441a04609b
21 changed files with 84 additions and 85 deletions

View File

@ -309,7 +309,7 @@ static void Http_socket_free(int SKey)
if (S->flags & HTTP_SOCKET_QUEUED) { if (S->flags & HTTP_SOCKET_QUEUED) {
S->flags |= HTTP_SOCKET_TO_BE_FREED; S->flags |= HTTP_SOCKET_TO_BE_FREED;
a_Url_free(S->url); delete S->url;
} else { } else {
if (S->SockFD != -1) if (S->SockFD != -1)
Http_fd_map_remove_entry(S->SockFD); Http_fd_map_remove_entry(S->SockFD);
@ -322,7 +322,7 @@ static void Http_socket_free(int SKey)
srv->active_conns--; srv->active_conns--;
Http_connect_queued_sockets(srv); Http_connect_queued_sockets(srv);
} }
a_Url_free(S->url); delete S->url;
dFree(S); dFree(S);
} }
} }
@ -1134,7 +1134,7 @@ void a_Http_freeall(void)
Http_servers_remove_all(); Http_servers_remove_all();
Http_fd_map_remove_all(); Http_fd_map_remove_all();
a_Klist_free(&ValidSocks); a_Klist_free(&ValidSocks);
a_Url_free(HTTP_Proxy); delete HTTP_Proxy;
dFree(HTTP_Proxy_Auth_base64); dFree(HTTP_Proxy_Auth_base64);
dFree(HTTP_Language_hdr); dFree(HTTP_Language_hdr);
} }

View File

@ -1092,7 +1092,7 @@ static void Tls_close_by_key(int connkey)
} }
SSL_free(c->ssl); SSL_free(c->ssl);
a_Url_free(c->url); delete c->url;
Tls_fd_map_remove_entry(c->fd); Tls_fd_map_remove_entry(c->fd);
a_Klist_remove(conn_list, connkey); a_Klist_remove(conn_list, connkey);
dFree(c); dFree(c);

View File

@ -635,7 +635,7 @@ static int Auth_do_auth_dialog(const AuthParse_t *auth_parse,
data->url = a_Url_dup(url); data->url = a_Url_dup(url);
ret = a_Dialog_user_password(title, msg, Auth_do_auth_dialog_cb, data); ret = a_Dialog_user_password(title, msg, Auth_do_auth_dialog_cb, data);
dFree(title); dFree(msg); dFree(title); dFree(msg);
a_Url_free(const_cast< DilloUrl * >( data->url )); delete const_cast< DilloUrl * >( data->url );
dFree(data); dFree(data);
return ret; return ret;
} }

View File

@ -98,16 +98,16 @@ void a_Bw_free(BrowserWindow *bw)
dList_free(bw->ImageClients); dList_free(bw->ImageClients);
dList_free(bw->Docs); dList_free(bw->Docs);
a_Url_free(bw->nav_expect_url); delete bw->nav_expect_url;
for (j = 0; j < dList_length(bw->PageUrls); ++j) for (j = 0; j < dList_length(bw->PageUrls); ++j)
a_Url_free(reinterpret_cast< DilloUrl * >( dList_nth_data(bw->PageUrls, j) )); delete reinterpret_cast< DilloUrl * >( dList_nth_data(bw->PageUrls, j) );
dList_free(bw->PageUrls); dList_free(bw->PageUrls);
for (j = 0; j < dList_length(bw->nav_stack); ++j) for (j = 0; j < dList_length(bw->nav_stack); ++j)
dFree(dList_nth_data(bw->nav_stack, j)); dFree(dList_nth_data(bw->nav_stack, j));
dList_free(bw->nav_stack); dList_free(bw->nav_stack);
a_Url_free(bw->meta_refresh_url); delete bw->meta_refresh_url;
dStr_free(bw->page_bugs, 1); dStr_free(bw->page_bugs, 1);
dFree(bw); dFree(bw);
@ -288,7 +288,7 @@ void a_Bw_cleanup(BrowserWindow *bw)
} }
/* Remove PageUrls */ /* Remove PageUrls */
while ((data = dList_nth_data(bw->PageUrls, 0))) { while ((data = dList_nth_data(bw->PageUrls, 0))) {
a_Url_free(reinterpret_cast< DilloUrl * >( data )); delete reinterpret_cast< DilloUrl * >( data );
dList_remove_fast(bw->PageUrls, data); dList_remove_fast(bw->PageUrls, data);
} }
@ -321,13 +321,13 @@ BrowserWindow *a_Bw_get(int i)
void a_Bw_expect(BrowserWindow *bw, const DilloUrl *url) void a_Bw_expect(BrowserWindow *bw, const DilloUrl *url)
{ {
a_Url_free(bw->nav_expect_url); delete bw->nav_expect_url;
bw->nav_expect_url = a_Url_dup(url); bw->nav_expect_url = a_Url_dup(url);
} }
void a_Bw_cancel_expect(BrowserWindow *bw) void a_Bw_cancel_expect(BrowserWindow *bw)
{ {
a_Url_free(bw->nav_expect_url); delete bw->nav_expect_url;
bw->nav_expect_url = NULL; bw->nav_expect_url = NULL;
} }

View File

@ -127,7 +127,7 @@ void a_Cache_init(void)
Dstr *ds = dStr_new(AboutSplash); Dstr *ds = dStr_new(AboutSplash);
Cache_entry_inject(url, ds); Cache_entry_inject(url, ds);
dStr_free(ds, 1); dStr_free(ds, 1);
a_Url_free(url); delete url;
} }
} }
@ -298,13 +298,13 @@ static void Cache_auth_free(Dlist *auth)
*/ */
static void Cache_entry_free(CacheEntry_t *entry) static void Cache_entry_free(CacheEntry_t *entry)
{ {
a_Url_free((DilloUrl *)entry->Url); delete const_cast< DilloUrl * >( entry->Url );
dFree(entry->TypeDet); dFree(entry->TypeDet);
dFree(entry->TypeHdr); dFree(entry->TypeHdr);
dFree(entry->TypeMeta); dFree(entry->TypeMeta);
dFree(entry->TypeNorm); dFree(entry->TypeNorm);
dStr_free(entry->Header, TRUE); dStr_free(entry->Header, TRUE);
a_Url_free((DilloUrl *)entry->Location); delete const_cast< DilloUrl * >( entry->Location );
Cache_auth_free(entry->Auth); Cache_auth_free(entry->Auth);
dStr_free(entry->Data, 1); dStr_free(entry->Data, 1);
dStr_free(entry->UTF8Data, 1); dStr_free(entry->UTF8Data, 1);
@ -1030,7 +1030,7 @@ static int Cache_redirect(CacheEntry_t *entry, int Flags, BrowserWindow *bw)
if (entry->Flags & CA_TempRedirect) if (entry->Flags & CA_TempRedirect)
a_Url_set_flags(NewUrl, URL_FLAGS(NewUrl) | URL_E2EQuery); a_Url_set_flags(NewUrl, URL_FLAGS(NewUrl) | URL_E2EQuery);
a_Nav_push(bw, NewUrl, entry->Url); a_Nav_push(bw, NewUrl, entry->Url);
a_Url_free(NewUrl); delete NewUrl;
} else { } else {
/* Sub entity redirection (most probably an image) */ /* Sub entity redirection (most probably an image) */
if (!entry->Data->len) { if (!entry->Data->len) {
@ -1058,7 +1058,7 @@ static void Cache_auth_callback(void *vdata)
if (a_Auth_do_auth(data->auth, data->url)) if (a_Auth_do_auth(data->auth, data->url))
a_Nav_reload(data->bw); a_Nav_reload(data->bw);
Cache_auth_free(data->auth); Cache_auth_free(data->auth);
a_Url_free(data->url); delete data->url;
dFree(data); dFree(data);
Cache_auth_entry(NULL, NULL); Cache_auth_entry(NULL, NULL);
a_Timeout_remove(); a_Timeout_remove();
@ -1136,7 +1136,7 @@ static void Cache_savelink_cb(void *vdata)
Cache_savelink_t *data = (Cache_savelink_t*) vdata; Cache_savelink_t *data = (Cache_savelink_t*) vdata;
a_UIcmd_save_link(data->bw, data->url); a_UIcmd_save_link(data->bw, data->url);
a_Url_free(data->url); delete data->url;
dFree(data); dFree(data);
} }
@ -1342,7 +1342,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
a_Timeout_add(0.0, Cache_savelink_cb, data); a_Timeout_add(0.0, Cache_savelink_cb, data);
} }
} }
a_Url_free(url); delete url;
} else if (entry->Auth && !(entry->Flags & CA_InProgress)) { } else if (entry->Auth && !(entry->Flags & CA_InProgress)) {
Cache_auth_entry(entry, Client_bw); Cache_auth_entry(entry, Client_bw);
} }

View File

@ -142,7 +142,7 @@ static void Capi_conn_unref(capi_conn_t *conn)
/* remove conn preserving the list order */ /* remove conn preserving the list order */
dList_remove(CapiConns, (void *)conn); dList_remove(CapiConns, (void *)conn);
/* free dynamic memory */ /* free dynamic memory */
a_Url_free(conn->url); delete conn->url;
dFree(conn->server); dFree(conn->server);
dFree(conn->datastr); dFree(conn->datastr);
dFree(conn); dFree(conn);
@ -223,7 +223,7 @@ void a_Capi_conn_abort_by_url(const DilloUrl *url)
*/ */
void a_Capi_set_vsource_url(const DilloUrl *url) void a_Capi_set_vsource_url(const DilloUrl *url)
{ {
a_Url_free(CapiVsUrl); delete CapiVsUrl;
CapiVsUrl = a_Url_dup(url); CapiVsUrl = a_Url_dup(url);
} }

View File

@ -1612,7 +1612,7 @@ char * CssParser::parseUrl()
if (urlStr) { if (urlStr) {
DilloUrl *dilloUrl = a_Url_new(urlStr->str, a_Url_str(this->baseUrl)); DilloUrl *dilloUrl = a_Url_new(urlStr->str, a_Url_str(this->baseUrl));
char *url = dStrdup(a_Url_str(dilloUrl)); char *url = dStrdup(a_Url_str(dilloUrl));
a_Url_free(dilloUrl); delete dilloUrl;
dStr_free(urlStr, 1); dStr_free(urlStr, 1);
return url; return url;
} else { } else {
@ -1669,7 +1669,7 @@ void CssParser::parseImport(DilloHtml *html)
DilloUrl *url = a_Html_url_new (html, urlStr, a_Url_str(this->baseUrl), DilloUrl *url = a_Html_url_new (html, urlStr, a_Url_str(this->baseUrl),
this->baseUrl ? 1 : 0); this->baseUrl ? 1 : 0);
a_Html_load_stylesheet(html, url); a_Html_load_stylesheet(html, url);
a_Url_free(url); delete url;
} }
dFree (urlStr); dFree (urlStr);
} }

View File

@ -181,7 +181,7 @@ static void Dicache_remove(const DilloUrl *Url, int version)
dicache_size_total -= entry->TotalSize; dicache_size_total -= entry->TotalSize;
/* entry cleanup */ /* entry cleanup */
a_Url_free(entry->url); delete entry->url;
dFree(entry->cmap); dFree(entry->cmap);
a_Bitvec_free(entry->BitVec); a_Bitvec_free(entry->BitVec);
a_Imgbuf_unref(entry->v_imgbuf); a_Imgbuf_unref(entry->v_imgbuf);
@ -590,7 +590,7 @@ void a_Dicache_freeall(void)
/* Remove all the dicache entries */ /* Remove all the dicache entries */
while ((entry = reinterpret_cast< DICacheEntry * >( dList_nth_data(CachedIMGs, dList_length(CachedIMGs)-1) ))) { while ((entry = reinterpret_cast< DICacheEntry * >( dList_nth_data(CachedIMGs, dList_length(CachedIMGs)-1) ))) {
dList_remove_fast(CachedIMGs, entry); dList_remove_fast(CachedIMGs, entry);
a_Url_free(entry->url); delete entry->url;
dFree(entry->cmap); dFree(entry->cmap);
a_Bitvec_free(entry->BitVec); a_Bitvec_free(entry->BitVec);
a_Imgbuf_unref(entry->v_imgbuf); a_Imgbuf_unref(entry->v_imgbuf);

View File

@ -594,7 +594,7 @@ int main(int argc, char **argv)
a_UIcmd_open_url(bw, start_url); a_UIcmd_open_url(bw, start_url);
a_UIcmd_set_location_text(bw, URL_STR(start_url)); a_UIcmd_set_location_text(bw, URL_STR(start_url));
} }
a_Url_free(start_url); delete start_url;
} }
} }

View File

@ -397,7 +397,7 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize)
charset = html->charset; charset = html->charset;
html->formNew(method, action, content_type, charset.has_value() ? charset.value().c_str() : nullptr ); html->formNew(method, action, content_type, charset.has_value() ? charset.value().c_str() : nullptr );
dFree(first); dFree(first);
a_Url_free(action); delete action;
} }
void Html_tag_close_form(DilloHtml *html) void Html_tag_close_form(DilloHtml *html)
@ -620,7 +620,7 @@ void Html_tag_open_isindex(DilloHtml *html, const char *tag, int tagsize)
HT2TB(html)->addWidget (embed, html->backgroundStyle ()); HT2TB(html)->addWidget (embed, html->backgroundStyle ());
a_Url_free(action); delete action;
html->InFlags &= ~IN_FORM; html->InFlags &= ~IN_FORM;
} }
@ -1011,7 +1011,7 @@ DilloHtmlForm::DilloHtmlForm (DilloHtml *html2,
*/ */
DilloHtmlForm::~DilloHtmlForm () DilloHtmlForm::~DilloHtmlForm ()
{ {
a_Url_free(action); delete action;
dFree(submit_charset); dFree(submit_charset);
inputs.clear(); inputs.clear();
if (form_receiver) if (form_receiver)
@ -1062,7 +1062,7 @@ void DilloHtmlForm::submit(DilloHtmlInput *active_input, EventButton *event)
} else { } else {
a_UIcmd_open_url(html->bw, url); a_UIcmd_open_url(html->bw, url);
} }
a_Url_free(url); delete url;
} }
} }

View File

@ -154,7 +154,7 @@ void a_History_freeall(void)
int i; int i;
for (i = 0; i < history_size; ++i) { for (i = 0; i < history_size; ++i) {
a_Url_free(history[i].url); delete history[i].url;
dFree(history[i].title); dFree(history[i].title);
} }
dFree(history); dFree(history);

View File

@ -541,11 +541,11 @@ DilloHtml::~DilloHtml()
a_Bw_remove_doc(bw, this); a_Bw_remove_doc(bw, this);
a_Url_free(page_url); delete page_url;
a_Url_free(base_url); delete base_url;
for (int i = 0; i < cssUrls->size(); i++) for (int i = 0; i < cssUrls->size(); i++)
a_Url_free(cssUrls->get(i)); delete cssUrls->get(i);
delete (cssUrls); delete (cssUrls);
for (std::size_t i = 0; i < forms.size(); i++) for (std::size_t i = 0; i < forms.size(); i++)
@ -558,12 +558,12 @@ DilloHtml::~DilloHtml()
// TODO: `DilloUrl` has to become RAII... // TODO: `DilloUrl` has to become RAII...
// TODO: In the interim, a `std::unique_ptr` deleter might // TODO: In the interim, a `std::unique_ptr` deleter might
// be a good choice. // be a good choice.
a_Url_free(link.release()); delete link.release(); // Once I have RAII correct on `DilloUrl`, I can make this not insane.
links.clear(); links.clear();
for (int i = 0; i < images->size(); i++) { for (int i = 0; i < images->size(); i++) {
DilloHtmlImage *img = images->get(i); DilloHtmlImage *img = images->get(i);
a_Url_free(img->url); delete img->url;
a_Image_unref(img->image); a_Image_unref(img->image);
dFree(img); dFree(img);
} }
@ -2301,7 +2301,7 @@ static void Html_tag_content_img(DilloHtml *html, const char *tag, int tagsize)
if (usemap_url) { if (usemap_url) {
dwi->setUseMap(&html->maps, new ::object::String(URL_STR(usemap_url))); dwi->setUseMap(&html->maps, new ::object::String(URL_STR(usemap_url)));
a_Url_free (usemap_url); delete usemap_url;
} }
} }
@ -2322,7 +2322,7 @@ static void Html_tag_content_map(DilloHtml *html, const char *tag, int tagsize)
hash_name = dStrconcat("#", attrbuf, NULL); hash_name = dStrconcat("#", attrbuf, NULL);
url = a_Html_url_new(html, hash_name, NULL, 0); url = a_Html_url_new(html, hash_name, NULL, 0);
html->maps.startNewMap(new ::object::String(URL_STR(url))); html->maps.startNewMap(new ::object::String(URL_STR(url)));
a_Url_free (url); delete url;
dFree(hash_name); dFree(hash_name);
} else { } else {
BUG_MSG("<map> requires name attribute."); BUG_MSG("<map> requires name attribute.");
@ -2490,7 +2490,7 @@ static void Html_tag_open_object(DilloHtml *html, const char *tag, int tagsize)
html->styleEngine->setNonCssHint(PROPERTY_X_LINK, CSS_TYPE_INTEGER, html->styleEngine->setNonCssHint(PROPERTY_X_LINK, CSS_TYPE_INTEGER,
Html_set_new_link(html, &url)); Html_set_new_link(html, &url));
} }
a_Url_free(base_url); delete base_url;
} }
static void Html_tag_content_object(DilloHtml *html, const char *tag, static void Html_tag_content_object(DilloHtml *html, const char *tag,
@ -3206,7 +3206,7 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize)
} }
dStr_free(ds_msg, 1); dStr_free(ds_msg, 1);
} }
a_Url_free(new_url); delete new_url;
dFree(mr_url); dFree(mr_url);
} else if (!dStrAsciiCasecmp(equiv, "content-type") && } else if (!dStrAsciiCasecmp(equiv, "content-type") &&
@ -3336,7 +3336,7 @@ static void Html_tag_open_link(DilloHtml *html, const char *tag, int tagsize)
_MSG(" Html_tag_open_link(): addCssUrl %s\n", URL_STR(url)); _MSG(" Html_tag_open_link(): addCssUrl %s\n", URL_STR(url));
html->addCssUrl(url); html->addCssUrl(url);
a_Url_free(url); delete url;
} }
/** /**
@ -3359,11 +3359,11 @@ static void Html_tag_open_base(DilloHtml *html, const char *tag, int tagsize)
/* Pass the URL_SpamSafe flag to the new base url */ /* Pass the URL_SpamSafe flag to the new base url */
a_Url_set_flags( a_Url_set_flags(
BaseUrl, URL_FLAGS(html->base_url) & URL_SpamSafe); BaseUrl, URL_FLAGS(html->base_url) & URL_SpamSafe);
a_Url_free(html->base_url); delete html->base_url;
html->base_url = BaseUrl; html->base_url = BaseUrl;
} else { } else {
BUG_MSG("<base> URI is relative (it MUST be absolute)."); BUG_MSG("<base> URI is relative (it MUST be absolute).");
a_Url_free(BaseUrl); delete BaseUrl;
} }
} }
} else { } else {

View File

@ -375,7 +375,7 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
popup_x = Fl::event_x(); popup_x = Fl::event_x();
popup_y = Fl::event_y(); popup_y = Fl::event_y();
popup_bw = bw; popup_bw = bw;
a_Url_free(popup_url); delete popup_url;
popup_url = a_Url_dup(url); popup_url = a_Url_dup(url);
has_bugs == TRUE ? pm[1].activate() : pm[1].deactivate(); has_bugs == TRUE ? pm[1].activate() : pm[1].deactivate();
@ -391,7 +391,7 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
if (stylesheets) { if (stylesheets) {
while (stylesheets[j].text) { while (stylesheets[j].text) {
dFree((char *) stylesheets[j].label()); dFree((char *) stylesheets[j].label());
a_Url_free((DilloUrl *) stylesheets[j].user_data()); delete reinterpret_cast< DilloUrl * >( stylesheets[j].user_data() );
j++; j++;
} }
delete [] stylesheets; delete [] stylesheets;
@ -554,7 +554,7 @@ void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url, const DilloUrl *p
popup_x = Fl::event_x(); popup_x = Fl::event_x();
popup_y = Fl::event_y(); popup_y = Fl::event_y();
popup_bw = bw; popup_bw = bw;
a_Url_free(popup_url); delete popup_url;
popup_url = a_Url_dup(url); popup_url = a_Url_dup(url);
Fl_Menu_Item *link_menu = get_link_menu(); Fl_Menu_Item *link_menu = get_link_menu();
@ -591,11 +591,11 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
popup_x = Fl::event_x(); popup_x = Fl::event_x();
popup_y = Fl::event_y(); popup_y = Fl::event_y();
popup_bw = bw; popup_bw = bw;
a_Url_free(popup_url); delete popup_url;
popup_url = a_Url_dup(url); popup_url = a_Url_dup(url);
a_Url_free(popup_page_url); delete popup_page_url;
popup_page_url = a_Url_dup(page_url); popup_page_url = a_Url_dup(page_url);
a_Url_free(popup_link_url); delete popup_link_url;
popup_link_url = a_Url_dup(link_url); popup_link_url = a_Url_dup(link_url);
@ -642,7 +642,7 @@ void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
popup_x = Fl::event_x(); popup_x = Fl::event_x();
popup_y = Fl::event_y(); popup_y = Fl::event_y();
popup_bw = bw; popup_bw = bw;
a_Url_free(popup_url); delete popup_url;
popup_url = a_Url_dup(page_url); popup_url = a_Url_dup(page_url);
popup_form = formptr; popup_form = formptr;
@ -678,7 +678,7 @@ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid)
popup_bw = bw; popup_bw = bw;
popup_x = wid->x(); popup_x = wid->x();
popup_y = wid->y() + wid->h(); popup_y = wid->y() + wid->h();
a_Url_free(popup_url); delete popup_url;
popup_url = NULL; popup_url = NULL;
//pm->label(wid->visible() ? NULL : "File"); //pm->label(wid->visible() ? NULL : "File");
@ -703,7 +703,7 @@ void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url)
popup_x = Fl::event_x(); popup_x = Fl::event_x();
popup_y = Fl::event_y(); popup_y = Fl::event_y();
popup_bw = bw; popup_bw = bw;
a_Url_free(popup_url); delete popup_url;
popup_url = a_Url_dup(url); popup_url = a_Url_dup(url);
a_Timeout_add(0.0, Menu_simple_popup_cb, (void*)pm); a_Timeout_add(0.0, Menu_simple_popup_cb, (void*)pm);

View File

@ -289,7 +289,7 @@ void a_Nav_expect_done(BrowserWindow *bw)
m = URL_E2EQuery|URL_ReloadPage|URL_ReloadFromCache|URL_IgnoreScroll; m = URL_E2EQuery|URL_ReloadPage|URL_ReloadFromCache|URL_IgnoreScroll;
a_Url_set_flags(url, URL_FLAGS(url) & ~m); a_Url_set_flags(url, URL_FLAGS(url) & ~m);
url_idx = a_History_add_url(url); url_idx = a_History_add_url(url);
a_Url_free(url); delete url;
if (repush) { if (repush) {
MSG("a_Nav_expect_done: repush!\n"); MSG("a_Nav_expect_done: repush!\n");
@ -371,7 +371,7 @@ static void Nav_repush(BrowserWindow *bw)
a_Url_set_flags(url, URL_FLAGS(url) | URL_ReloadFromCache); a_Url_set_flags(url, URL_FLAGS(url) | URL_ReloadFromCache);
a_Bw_expect(bw, url); a_Bw_expect(bw, url);
Nav_open_url(bw, url, NULL, 0); Nav_open_url(bw, url, NULL, 0);
a_Url_free(url); delete url;
} }
} }
@ -410,7 +410,7 @@ static void Nav_redirection0_callback(void *data)
Nav_stack_move_ptr(bw, -1); Nav_stack_move_ptr(bw, -1);
a_Nav_push(bw, bw->meta_refresh_url, referer_url); a_Nav_push(bw, bw->meta_refresh_url, referer_url);
} }
a_Url_free(bw->meta_refresh_url); delete bw->meta_refresh_url;
bw->meta_refresh_url = NULL; bw->meta_refresh_url = NULL;
bw->meta_refresh_status = 0; bw->meta_refresh_status = 0;
a_Timeout_remove(); a_Timeout_remove();
@ -424,7 +424,7 @@ void a_Nav_redirection0(BrowserWindow *bw, const DilloUrl *new_url)
dReturn_if_fail (bw != NULL); dReturn_if_fail (bw != NULL);
_MSG(">>>> a_Nav_redirection0 <<<<\n"); _MSG(">>>> a_Nav_redirection0 <<<<\n");
a_Url_free(bw->meta_refresh_url); delete bw->meta_refresh_url;
bw->meta_refresh_url = a_Url_dup(new_url); bw->meta_refresh_url = a_Url_dup(new_url);
a_Url_set_flags(bw->meta_refresh_url, a_Url_set_flags(bw->meta_refresh_url,
URL_FLAGS(new_url)|URL_E2EQuery|URL_IgnoreScroll); URL_FLAGS(new_url)|URL_E2EQuery|URL_IgnoreScroll);
@ -503,7 +503,7 @@ static void Nav_reload_callback(void *data)
a_Url_set_flags(r_url, URL_FLAGS(r_url) & ~URL_SpamSafe); a_Url_set_flags(r_url, URL_FLAGS(r_url) & ~URL_SpamSafe);
a_Bw_expect(bw, r_url); a_Bw_expect(bw, r_url);
Nav_open_url(bw, r_url, NULL, 0); Nav_open_url(bw, r_url, NULL, 0);
a_Url_free(r_url); delete r_url;
} }
} }
} }

View File

@ -151,9 +151,9 @@ void a_Prefs_freeall(void)
dFree(prefs.font_monospace); dFree(prefs.font_monospace);
dFree(prefs.font_sans_serif); dFree(prefs.font_sans_serif);
dFree(prefs.font_serif); dFree(prefs.font_serif);
a_Url_free(prefs.home); delete prefs.home;
dFree(prefs.http_language); dFree(prefs.http_language);
a_Url_free(prefs.http_proxy); delete prefs.http_proxy;
dFree(prefs.http_proxyuser); dFree(prefs.http_proxyuser);
dFree(prefs.http_referer); dFree(prefs.http_referer);
dFree(prefs.http_user_agent); dFree(prefs.http_user_agent);
@ -162,7 +162,7 @@ void a_Prefs_freeall(void)
for (i = 0; i < dList_length(prefs.search_urls); ++i) for (i = 0; i < dList_length(prefs.search_urls); ++i)
dFree(dList_nth_data(prefs.search_urls, i)); dFree(dList_nth_data(prefs.search_urls, i));
dList_free(prefs.search_urls); dList_free(prefs.search_urls);
a_Url_free(prefs.start_page); delete prefs.start_page;
a_Url_free(prefs.new_tab_page); delete prefs.new_tab_page;
dFree(prefs.theme); dFree(prefs.theme);
} }

View File

@ -100,7 +100,7 @@ static int parseOption(char *name, char *value,
break; break;
} }
case PREFS_URL: case PREFS_URL:
a_Url_free(*(DilloUrl **)node->pref); delete *(DilloUrl **)node->pref;
*(DilloUrl **)node->pref = a_Url_new(value, NULL); *(DilloUrl **)node->pref = a_Url_new(value, NULL);
break; break;
case PREFS_INT32: case PREFS_INT32:

View File

@ -108,8 +108,8 @@ StyleEngine::~StyleEngine () {
stackPop (); // dummy node on the bottom of the stack stackPop (); // dummy node on the bottom of the stack
assert (stack.size () == 0); assert (stack.size () == 0);
a_Url_free(pageUrl); delete pageUrl;
a_Url_free(baseUrl); delete baseUrl;
delete doctree; delete doctree;
delete cssContext; delete cssContext;
@ -779,7 +779,7 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props,
(new StyleImageDeletionReceiver (clientKey)); (new StyleImageDeletionReceiver (clientKey));
} }
} }
a_Url_free (imgUrl); delete imgUrl;
} }
/** /**

View File

@ -789,7 +789,7 @@ void a_UIcmd_open_urlstr(void *vbw, const char *urlstr)
if (url) { if (url) {
a_UIcmd_open_url(bw, url); a_UIcmd_open_url(bw, url);
a_Url_free(url); delete url;
} }
} }
dFree(search_urlstr); dFree(search_urlstr);
@ -1159,7 +1159,7 @@ void a_UIcmd_open_file(void *vbw)
if (name.has_value()) { if (name.has_value()) {
url = a_Url_new(name.value().c_str(), "file:"); url = a_Url_new(name.value().c_str(), "file:");
a_UIcmd_open_url((BrowserWindow*)vbw, url); a_UIcmd_open_url((BrowserWindow*)vbw, url);
a_Url_free(url); delete url;
} }
} }
@ -1242,7 +1242,7 @@ void a_UIcmd_book(void *vbw)
{ {
DilloUrl *url = a_Url_new("dpi:/bm/", NULL); DilloUrl *url = a_Url_new("dpi:/bm/", NULL);
a_UIcmd_open_url((BrowserWindow*)vbw, url); a_UIcmd_open_url((BrowserWindow*)vbw, url);
a_Url_free(url); delete url;
} }
/* /*
@ -1335,7 +1335,7 @@ void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
} }
vs_url = a_Url_new(dstr_url->str, NULL); vs_url = a_Url_new(dstr_url->str, NULL);
a_UIcmd_open_url_nt(bw, vs_url, 1); a_UIcmd_open_url_nt(bw, vs_url, 1);
a_Url_free(vs_url); delete vs_url;
dStr_free(dstr_url, 1); dStr_free(dstr_url, 1);
a_Nav_unref_buf(url); a_Nav_unref_buf(url);
} }

View File

@ -205,17 +205,14 @@ static DilloUrl *Url_object_new(const char *uri_str)
* Free a DilloUrl. * Free a DilloUrl.
* Do nothing if the argument is NULL * Do nothing if the argument is NULL
*/ */
void a_Url_free(DilloUrl *url) DilloUrl::~DilloUrl()
{ {
if (url) { if (this->url_string)
if (url->url_string) dStr_free(this->url_string, TRUE);
dStr_free(url->url_string, TRUE); if (this->hostname != this->authority)
if (url->hostname != url->authority) dFree((char *)this->hostname);
dFree((char *)url->hostname); dFree((char *)this->buffer);
dFree((char *)url->buffer); dStr_free(this->data, 1);
dStr_free(url->data, 1);
dFree(url);
}
} }
/** /**
@ -341,8 +338,8 @@ static Dstr *Url_resolve_relative(const char *RelStr,
done: done:
dStr_free(Path, TRUE); dStr_free(Path, TRUE);
a_Url_free(RelUrl); delete RelUrl;
a_Url_free(BaseUrl); delete BaseUrl;
return SolvedUrl; return SolvedUrl;
} }

View File

@ -87,7 +87,7 @@ extern "C" {
#error URL header is now C++ #error URL header is now C++
#endif /* __cplusplus */ #endif /* __cplusplus */
typedef struct { struct DilloUrl {
Dstr *url_string; Dstr *url_string;
const char *buffer; const char *buffer;
const char *scheme; /**/ const char *scheme; /**/
@ -102,11 +102,13 @@ typedef struct {
int ismap_url_len; /**< Used by server side image maps */ int ismap_url_len; /**< Used by server side image maps */
int illegal_chars; /**< number of illegal chars */ int illegal_chars; /**< number of illegal chars */
int illegal_chars_spc; /**< number of illegal space chars */ int illegal_chars_spc; /**< number of illegal space chars */
} DilloUrl;
~DilloUrl();
};
DilloUrl* a_Url_new(const char *url_str, const char *base_url); DilloUrl* a_Url_new(const char *url_str, const char *base_url);
void a_Url_free(DilloUrl *u);
char *a_Url_str(const DilloUrl *url); char *a_Url_str(const DilloUrl *url);
const char *a_Url_hostname(const DilloUrl *u); const char *a_Url_hostname(const DilloUrl *u);
DilloUrl* a_Url_dup(const DilloUrl *u); DilloUrl* a_Url_dup(const DilloUrl *u);

View File

@ -152,8 +152,8 @@ int a_Web_valid(DilloWeb *web)
void a_Web_free(DilloWeb *web) void a_Web_free(DilloWeb *web)
{ {
if (!web) return; if (!web) return;
a_Url_free(web->url); delete web->url;
a_Url_free(web->requester); delete web->requester;
a_Image_unref(web->Image); a_Image_unref(web->Image);
dFree(web->filename); dFree(web->filename);
dList_remove(ValidWebs, (void *)web); dList_remove(ValidWebs, (void *)web);