From 441a04609b3f5166cbd1ce291739385c439fd2edf11bdd86c92c423a2a25ea2c Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 12 Apr 2025 04:08:14 -0400 Subject: [PATCH] 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. --- src/IO/http.cc | 6 +++--- src/IO/tls_openssl.cc | 2 +- src/auth.cc | 2 +- src/bw.cc | 12 ++++++------ src/cache.cc | 14 +++++++------- src/capi.cc | 4 ++-- src/cssparser.cc | 4 ++-- src/dicache.cc | 4 ++-- src/flenser.cc | 2 +- src/form.cc | 8 ++++---- src/history.cc | 2 +- src/html.cc | 24 ++++++++++++------------ src/menu.cc | 18 +++++++++--------- src/nav.cc | 10 +++++----- src/prefs.cc | 8 ++++---- src/prefsparser.cc | 2 +- src/styleengine.cc | 6 +++--- src/uicmd.cc | 8 ++++---- src/url.cc | 21 +++++++++------------ src/url.hh | 8 +++++--- src/web.cc | 4 ++-- 21 files changed, 84 insertions(+), 85 deletions(-) diff --git a/src/IO/http.cc b/src/IO/http.cc index 651c2e1..14b5286 100644 --- a/src/IO/http.cc +++ b/src/IO/http.cc @@ -309,7 +309,7 @@ static void Http_socket_free(int SKey) if (S->flags & HTTP_SOCKET_QUEUED) { S->flags |= HTTP_SOCKET_TO_BE_FREED; - a_Url_free(S->url); + delete S->url; } else { if (S->SockFD != -1) Http_fd_map_remove_entry(S->SockFD); @@ -322,7 +322,7 @@ static void Http_socket_free(int SKey) srv->active_conns--; Http_connect_queued_sockets(srv); } - a_Url_free(S->url); + delete S->url; dFree(S); } } @@ -1134,7 +1134,7 @@ void a_Http_freeall(void) Http_servers_remove_all(); Http_fd_map_remove_all(); a_Klist_free(&ValidSocks); - a_Url_free(HTTP_Proxy); + delete HTTP_Proxy; dFree(HTTP_Proxy_Auth_base64); dFree(HTTP_Language_hdr); } diff --git a/src/IO/tls_openssl.cc b/src/IO/tls_openssl.cc index 6a79901..aced22d 100644 --- a/src/IO/tls_openssl.cc +++ b/src/IO/tls_openssl.cc @@ -1092,7 +1092,7 @@ static void Tls_close_by_key(int connkey) } SSL_free(c->ssl); - a_Url_free(c->url); + delete c->url; Tls_fd_map_remove_entry(c->fd); a_Klist_remove(conn_list, connkey); dFree(c); diff --git a/src/auth.cc b/src/auth.cc index de3484a..fd2a1a0 100644 --- a/src/auth.cc +++ b/src/auth.cc @@ -635,7 +635,7 @@ static int Auth_do_auth_dialog(const AuthParse_t *auth_parse, data->url = a_Url_dup(url); ret = a_Dialog_user_password(title, msg, Auth_do_auth_dialog_cb, data); dFree(title); dFree(msg); - a_Url_free(const_cast< DilloUrl * >( data->url )); + delete const_cast< DilloUrl * >( data->url ); dFree(data); return ret; } diff --git a/src/bw.cc b/src/bw.cc index 74c9a29..c20d734 100644 --- a/src/bw.cc +++ b/src/bw.cc @@ -98,16 +98,16 @@ void a_Bw_free(BrowserWindow *bw) dList_free(bw->ImageClients); 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) - 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); for (j = 0; j < dList_length(bw->nav_stack); ++j) dFree(dList_nth_data(bw->nav_stack, j)); dList_free(bw->nav_stack); - a_Url_free(bw->meta_refresh_url); + delete bw->meta_refresh_url; dStr_free(bw->page_bugs, 1); dFree(bw); @@ -288,7 +288,7 @@ void a_Bw_cleanup(BrowserWindow *bw) } /* Remove PageUrls */ 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); } @@ -321,13 +321,13 @@ BrowserWindow *a_Bw_get(int i) 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); } void a_Bw_cancel_expect(BrowserWindow *bw) { - a_Url_free(bw->nav_expect_url); + delete bw->nav_expect_url; bw->nav_expect_url = NULL; } diff --git a/src/cache.cc b/src/cache.cc index 59ff2a2..ac04dc0 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -127,7 +127,7 @@ void a_Cache_init(void) Dstr *ds = dStr_new(AboutSplash); Cache_entry_inject(url, ds); 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) { - a_Url_free((DilloUrl *)entry->Url); + delete const_cast< DilloUrl * >( entry->Url ); dFree(entry->TypeDet); dFree(entry->TypeHdr); dFree(entry->TypeMeta); dFree(entry->TypeNorm); dStr_free(entry->Header, TRUE); - a_Url_free((DilloUrl *)entry->Location); + delete const_cast< DilloUrl * >( entry->Location ); Cache_auth_free(entry->Auth); dStr_free(entry->Data, 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) a_Url_set_flags(NewUrl, URL_FLAGS(NewUrl) | URL_E2EQuery); a_Nav_push(bw, NewUrl, entry->Url); - a_Url_free(NewUrl); + delete NewUrl; } else { /* Sub entity redirection (most probably an image) */ if (!entry->Data->len) { @@ -1058,7 +1058,7 @@ static void Cache_auth_callback(void *vdata) if (a_Auth_do_auth(data->auth, data->url)) a_Nav_reload(data->bw); Cache_auth_free(data->auth); - a_Url_free(data->url); + delete data->url; dFree(data); Cache_auth_entry(NULL, NULL); a_Timeout_remove(); @@ -1136,7 +1136,7 @@ static void Cache_savelink_cb(void *vdata) Cache_savelink_t *data = (Cache_savelink_t*) vdata; a_UIcmd_save_link(data->bw, data->url); - a_Url_free(data->url); + delete data->url; 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_Url_free(url); + delete url; } else if (entry->Auth && !(entry->Flags & CA_InProgress)) { Cache_auth_entry(entry, Client_bw); } diff --git a/src/capi.cc b/src/capi.cc index 2d34aa3..1b94d76 100644 --- a/src/capi.cc +++ b/src/capi.cc @@ -142,7 +142,7 @@ static void Capi_conn_unref(capi_conn_t *conn) /* remove conn preserving the list order */ dList_remove(CapiConns, (void *)conn); /* free dynamic memory */ - a_Url_free(conn->url); + delete conn->url; dFree(conn->server); dFree(conn->datastr); 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) { - a_Url_free(CapiVsUrl); + delete CapiVsUrl; CapiVsUrl = a_Url_dup(url); } diff --git a/src/cssparser.cc b/src/cssparser.cc index 67ca56c..6ee9ec4 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -1612,7 +1612,7 @@ char * CssParser::parseUrl() if (urlStr) { DilloUrl *dilloUrl = a_Url_new(urlStr->str, a_Url_str(this->baseUrl)); char *url = dStrdup(a_Url_str(dilloUrl)); - a_Url_free(dilloUrl); + delete dilloUrl; dStr_free(urlStr, 1); return url; } else { @@ -1669,7 +1669,7 @@ void CssParser::parseImport(DilloHtml *html) DilloUrl *url = a_Html_url_new (html, urlStr, a_Url_str(this->baseUrl), this->baseUrl ? 1 : 0); a_Html_load_stylesheet(html, url); - a_Url_free(url); + delete url; } dFree (urlStr); } diff --git a/src/dicache.cc b/src/dicache.cc index 52b271f..66cbd03 100644 --- a/src/dicache.cc +++ b/src/dicache.cc @@ -181,7 +181,7 @@ static void Dicache_remove(const DilloUrl *Url, int version) dicache_size_total -= entry->TotalSize; /* entry cleanup */ - a_Url_free(entry->url); + delete entry->url; dFree(entry->cmap); a_Bitvec_free(entry->BitVec); a_Imgbuf_unref(entry->v_imgbuf); @@ -590,7 +590,7 @@ void a_Dicache_freeall(void) /* Remove all the dicache entries */ while ((entry = reinterpret_cast< DICacheEntry * >( dList_nth_data(CachedIMGs, dList_length(CachedIMGs)-1) ))) { dList_remove_fast(CachedIMGs, entry); - a_Url_free(entry->url); + delete entry->url; dFree(entry->cmap); a_Bitvec_free(entry->BitVec); a_Imgbuf_unref(entry->v_imgbuf); diff --git a/src/flenser.cc b/src/flenser.cc index c245765..e12b85b 100644 --- a/src/flenser.cc +++ b/src/flenser.cc @@ -594,7 +594,7 @@ int main(int argc, char **argv) a_UIcmd_open_url(bw, start_url); a_UIcmd_set_location_text(bw, URL_STR(start_url)); } - a_Url_free(start_url); + delete start_url; } } diff --git a/src/form.cc b/src/form.cc index c7b4a63..091364b 100644 --- a/src/form.cc +++ b/src/form.cc @@ -397,7 +397,7 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize) charset = html->charset; html->formNew(method, action, content_type, charset.has_value() ? charset.value().c_str() : nullptr ); dFree(first); - a_Url_free(action); + delete action; } 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 ()); - a_Url_free(action); + delete action; html->InFlags &= ~IN_FORM; } @@ -1011,7 +1011,7 @@ DilloHtmlForm::DilloHtmlForm (DilloHtml *html2, */ DilloHtmlForm::~DilloHtmlForm () { - a_Url_free(action); + delete action; dFree(submit_charset); inputs.clear(); if (form_receiver) @@ -1062,7 +1062,7 @@ void DilloHtmlForm::submit(DilloHtmlInput *active_input, EventButton *event) } else { a_UIcmd_open_url(html->bw, url); } - a_Url_free(url); + delete url; } } diff --git a/src/history.cc b/src/history.cc index ae94d1e..dc04a0a 100644 --- a/src/history.cc +++ b/src/history.cc @@ -154,7 +154,7 @@ void a_History_freeall(void) int i; for (i = 0; i < history_size; ++i) { - a_Url_free(history[i].url); + delete history[i].url; dFree(history[i].title); } dFree(history); diff --git a/src/html.cc b/src/html.cc index a7d0b2e..0ec51e3 100644 --- a/src/html.cc +++ b/src/html.cc @@ -541,11 +541,11 @@ DilloHtml::~DilloHtml() a_Bw_remove_doc(bw, this); - a_Url_free(page_url); - a_Url_free(base_url); + delete page_url; + delete base_url; for (int i = 0; i < cssUrls->size(); i++) - a_Url_free(cssUrls->get(i)); + delete cssUrls->get(i); delete (cssUrls); for (std::size_t i = 0; i < forms.size(); i++) @@ -558,12 +558,12 @@ DilloHtml::~DilloHtml() // 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()); + delete link.release(); // Once I have RAII correct on `DilloUrl`, I can make this not insane. links.clear(); for (int i = 0; i < images->size(); i++) { DilloHtmlImage *img = images->get(i); - a_Url_free(img->url); + delete img->url; a_Image_unref(img->image); dFree(img); } @@ -2301,7 +2301,7 @@ static void Html_tag_content_img(DilloHtml *html, const char *tag, int tagsize) if (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); url = a_Html_url_new(html, hash_name, NULL, 0); html->maps.startNewMap(new ::object::String(URL_STR(url))); - a_Url_free (url); + delete url; dFree(hash_name); } else { BUG_MSG(" 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_set_new_link(html, &url)); } - a_Url_free(base_url); + delete base_url; } 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); } - a_Url_free(new_url); + delete new_url; dFree(mr_url); } 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)); 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 */ a_Url_set_flags( BaseUrl, URL_FLAGS(html->base_url) & URL_SpamSafe); - a_Url_free(html->base_url); + delete html->base_url; html->base_url = BaseUrl; } else { BUG_MSG(" URI is relative (it MUST be absolute)."); - a_Url_free(BaseUrl); + delete BaseUrl; } } } else { diff --git a/src/menu.cc b/src/menu.cc index af68f78..97adea9 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -375,7 +375,7 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url, popup_x = Fl::event_x(); popup_y = Fl::event_y(); popup_bw = bw; - a_Url_free(popup_url); + delete popup_url; popup_url = a_Url_dup(url); 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) { while (stylesheets[j].text) { dFree((char *) stylesheets[j].label()); - a_Url_free((DilloUrl *) stylesheets[j].user_data()); + delete reinterpret_cast< DilloUrl * >( stylesheets[j].user_data() ); j++; } 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_y = Fl::event_y(); popup_bw = bw; - a_Url_free(popup_url); + delete popup_url; popup_url = a_Url_dup(url); 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_y = Fl::event_y(); popup_bw = bw; - a_Url_free(popup_url); + delete popup_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); - a_Url_free(popup_link_url); + delete popup_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_y = Fl::event_y(); popup_bw = bw; - a_Url_free(popup_url); + delete popup_url; popup_url = a_Url_dup(page_url); popup_form = formptr; @@ -678,7 +678,7 @@ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid) popup_bw = bw; popup_x = wid->x(); popup_y = wid->y() + wid->h(); - a_Url_free(popup_url); + delete popup_url; popup_url = NULL; //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_y = Fl::event_y(); popup_bw = bw; - a_Url_free(popup_url); + delete popup_url; popup_url = a_Url_dup(url); a_Timeout_add(0.0, Menu_simple_popup_cb, (void*)pm); diff --git a/src/nav.cc b/src/nav.cc index 3248242..8de1560 100644 --- a/src/nav.cc +++ b/src/nav.cc @@ -289,7 +289,7 @@ void a_Nav_expect_done(BrowserWindow *bw) m = URL_E2EQuery|URL_ReloadPage|URL_ReloadFromCache|URL_IgnoreScroll; a_Url_set_flags(url, URL_FLAGS(url) & ~m); url_idx = a_History_add_url(url); - a_Url_free(url); + delete url; if (repush) { 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_Bw_expect(bw, url); 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); 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_status = 0; a_Timeout_remove(); @@ -424,7 +424,7 @@ void a_Nav_redirection0(BrowserWindow *bw, const DilloUrl *new_url) dReturn_if_fail (bw != NULL); _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); a_Url_set_flags(bw->meta_refresh_url, 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_Bw_expect(bw, r_url); Nav_open_url(bw, r_url, NULL, 0); - a_Url_free(r_url); + delete r_url; } } } diff --git a/src/prefs.cc b/src/prefs.cc index f2a7749..79ff7b3 100644 --- a/src/prefs.cc +++ b/src/prefs.cc @@ -151,9 +151,9 @@ void a_Prefs_freeall(void) dFree(prefs.font_monospace); dFree(prefs.font_sans_serif); dFree(prefs.font_serif); - a_Url_free(prefs.home); + delete prefs.home; dFree(prefs.http_language); - a_Url_free(prefs.http_proxy); + delete prefs.http_proxy; dFree(prefs.http_proxyuser); dFree(prefs.http_referer); dFree(prefs.http_user_agent); @@ -162,7 +162,7 @@ void a_Prefs_freeall(void) for (i = 0; i < dList_length(prefs.search_urls); ++i) dFree(dList_nth_data(prefs.search_urls, i)); dList_free(prefs.search_urls); - a_Url_free(prefs.start_page); - a_Url_free(prefs.new_tab_page); + delete prefs.start_page; + delete prefs.new_tab_page; dFree(prefs.theme); } diff --git a/src/prefsparser.cc b/src/prefsparser.cc index 36706a8..128ea30 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -100,7 +100,7 @@ static int parseOption(char *name, char *value, break; } case PREFS_URL: - a_Url_free(*(DilloUrl **)node->pref); + delete *(DilloUrl **)node->pref; *(DilloUrl **)node->pref = a_Url_new(value, NULL); break; case PREFS_INT32: diff --git a/src/styleengine.cc b/src/styleengine.cc index 92e983e..a863f42 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -108,8 +108,8 @@ StyleEngine::~StyleEngine () { stackPop (); // dummy node on the bottom of the stack assert (stack.size () == 0); - a_Url_free(pageUrl); - a_Url_free(baseUrl); + delete pageUrl; + delete baseUrl; delete doctree; delete cssContext; @@ -779,7 +779,7 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props, (new StyleImageDeletionReceiver (clientKey)); } } - a_Url_free (imgUrl); + delete imgUrl; } /** diff --git a/src/uicmd.cc b/src/uicmd.cc index a74bb69..7d8b408 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -789,7 +789,7 @@ void a_UIcmd_open_urlstr(void *vbw, const char *urlstr) if (url) { a_UIcmd_open_url(bw, url); - a_Url_free(url); + delete url; } } dFree(search_urlstr); @@ -1159,7 +1159,7 @@ void a_UIcmd_open_file(void *vbw) if (name.has_value()) { url = a_Url_new(name.value().c_str(), "file:"); 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); 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); a_UIcmd_open_url_nt(bw, vs_url, 1); - a_Url_free(vs_url); + delete vs_url; dStr_free(dstr_url, 1); a_Nav_unref_buf(url); } diff --git a/src/url.cc b/src/url.cc index b8e765f..e7919e5 100644 --- a/src/url.cc +++ b/src/url.cc @@ -205,17 +205,14 @@ static DilloUrl *Url_object_new(const char *uri_str) * Free a DilloUrl. * Do nothing if the argument is NULL */ -void a_Url_free(DilloUrl *url) +DilloUrl::~DilloUrl() { - if (url) { - if (url->url_string) - dStr_free(url->url_string, TRUE); - if (url->hostname != url->authority) - dFree((char *)url->hostname); - dFree((char *)url->buffer); - dStr_free(url->data, 1); - dFree(url); - } + if (this->url_string) + dStr_free(this->url_string, TRUE); + if (this->hostname != this->authority) + dFree((char *)this->hostname); + dFree((char *)this->buffer); + dStr_free(this->data, 1); } /** @@ -341,8 +338,8 @@ static Dstr *Url_resolve_relative(const char *RelStr, done: dStr_free(Path, TRUE); - a_Url_free(RelUrl); - a_Url_free(BaseUrl); + delete RelUrl; + delete BaseUrl; return SolvedUrl; } diff --git a/src/url.hh b/src/url.hh index d45c77e..0ca1ff0 100644 --- a/src/url.hh +++ b/src/url.hh @@ -87,7 +87,7 @@ extern "C" { #error URL header is now C++ #endif /* __cplusplus */ -typedef struct { +struct DilloUrl { Dstr *url_string; const char *buffer; const char *scheme; /**/ @@ -102,11 +102,13 @@ typedef struct { int ismap_url_len; /**< Used by server side image maps */ int illegal_chars; /**< number of illegal chars */ int illegal_chars_spc; /**< number of illegal space chars */ -} DilloUrl; + + ~DilloUrl(); +}; 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); const char *a_Url_hostname(const DilloUrl *u); DilloUrl* a_Url_dup(const DilloUrl *u); diff --git a/src/web.cc b/src/web.cc index 6a5d79b..868b5fa 100644 --- a/src/web.cc +++ b/src/web.cc @@ -152,8 +152,8 @@ int a_Web_valid(DilloWeb *web) void a_Web_free(DilloWeb *web) { if (!web) return; - a_Url_free(web->url); - a_Url_free(web->requester); + delete web->url; + delete web->requester; a_Image_unref(web->Image); dFree(web->filename); dList_remove(ValidWebs, (void *)web);