From 339bed72725fe901724440939558c5f9817107ed Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 15 Sep 2011 22:47:50 +0000 Subject: Virtualise content handler finalisation calls. Remove pointless implementations. svn path=/trunk/netsurf/; revision=12797 --- amiga/datatypes.c | 8 ------- amiga/datatypes.h | 5 ---- amiga/dt_anim.c | 5 ---- amiga/dt_picture.c | 5 ---- amiga/dt_sound.c | 5 ---- amiga/gui.c | 4 ---- amiga/plugin_hack.c | 5 ---- amiga/plugin_hack.h | 1 - cocoa/NetsurfApp.m | 2 -- cocoa/apple_image.h | 2 -- cocoa/apple_image.m | 4 ---- content/content_factory.c | 3 +++ content/content_factory.h | 13 ++--------- content/content_protected.h | 2 ++ css/css.c | 6 +++-- css/css.h | 3 +-- desktop/netsurf.c | 9 ++----- image/bmp.h | 1 - image/gif.h | 1 - image/ico.h | 1 - image/image.c | 48 -------------------------------------- image/image.h | 1 - image/jpeg.h | 1 - image/mng.h | 3 --- image/nssprite.h | 1 - image/png.h | 1 - image/rsvg.h | 1 - image/svg.h | 1 - image/webp.h | 1 - render/html.c | 2 ++ render/html.h | 1 - render/textplain.c | 2 ++ render/textplain.h | 1 - riscos/content-handlers/artworks.h | 2 -- riscos/content-handlers/draw.h | 2 -- riscos/content-handlers/sprite.h | 2 -- riscos/gui.c | 4 ---- 37 files changed, 18 insertions(+), 141 deletions(-) diff --git a/amiga/datatypes.c b/amiga/datatypes.c index c036ed35e..6018b107f 100644 --- a/amiga/datatypes.c +++ b/amiga/datatypes.c @@ -37,12 +37,4 @@ nserror amiga_datatypes_init(void) return NSERROR_OK; } -void amiga_datatypes_fini(void) -{ - amiga_dt_picture_fini(); -#ifdef WITH_DTANIM - amiga_dt_anim_fini(); -#endif - amiga_dt_sound_fini(); -} #endif diff --git a/amiga/datatypes.h b/amiga/datatypes.h index 18aa9b161..00a9b4e5a 100644 --- a/amiga/datatypes.h +++ b/amiga/datatypes.h @@ -25,21 +25,16 @@ #ifdef WITH_AMIGA_DATATYPES nserror amiga_datatypes_init(void); -void amiga_datatypes_fini(void); nserror amiga_dt_picture_init(void); -void amiga_dt_picture_fini(void); nserror amiga_dt_anim_init(void); -void amiga_dt_anim_fini(void); nserror amiga_dt_sound_init(void); -void amiga_dt_sound_fini(void); #else #define amiga_datatypes_init() NSERROR_OK -#define amiga_datatypes_fini() ((void) 0) #endif /* WITH_AMIGA_DATATYPES */ diff --git a/amiga/dt_anim.c b/amiga/dt_anim.c index 478aa149b..d92bfae6f 100644 --- a/amiga/dt_anim.c +++ b/amiga/dt_anim.c @@ -133,11 +133,6 @@ nserror amiga_dt_anim_init(void) return NSERROR_OK; } -void amiga_dt_anim_fini(void) -{ - /* Nothing to do */ -} - nserror amiga_dt_anim_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, diff --git a/amiga/dt_picture.c b/amiga/dt_picture.c index 304506b06..da39c2936 100644 --- a/amiga/dt_picture.c +++ b/amiga/dt_picture.c @@ -120,11 +120,6 @@ nserror amiga_dt_picture_init(void) return NSERROR_OK; } -void amiga_dt_picture_fini(void) -{ - /* Nothing to do */ -} - nserror amiga_dt_picture_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, diff --git a/amiga/dt_sound.c b/amiga/dt_sound.c index c4c8e99a1..386ffe220 100644 --- a/amiga/dt_sound.c +++ b/amiga/dt_sound.c @@ -117,11 +117,6 @@ nserror amiga_dt_sound_init(void) return NSERROR_OK; } -void amiga_dt_sound_fini(void) -{ - /* Nothing to do */ -} - nserror amiga_dt_sound_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, diff --git a/amiga/gui.c b/amiga/gui.c index 7d8521c52..c632d238d 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -785,10 +785,6 @@ int main(int argc, char** argv) netsurf_exit(); - amiga_plugin_hack_fini(); - amiga_datatypes_fini(); - amiga_icon_fini(); - ami_mime_free(); return 0; diff --git a/amiga/plugin_hack.c b/amiga/plugin_hack.c index 9159cddb0..8809a7bea 100644 --- a/amiga/plugin_hack.c +++ b/amiga/plugin_hack.c @@ -94,11 +94,6 @@ nserror amiga_plugin_hack_init(void) return NSERROR_OK; } -void amiga_plugin_hack_fini(void) -{ - /* Nothing to do */ -} - nserror amiga_plugin_hack_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, diff --git a/amiga/plugin_hack.h b/amiga/plugin_hack.h index 0e9629996..ae79a1f91 100644 --- a/amiga/plugin_hack.h +++ b/amiga/plugin_hack.h @@ -25,7 +25,6 @@ struct hlcache_handle; nserror amiga_plugin_hack_init(void); -void amiga_plugin_hack_fini(void); void amiga_plugin_hack_execute(struct hlcache_handle *c); #endif diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m index d8dda678e..2194b966c 100644 --- a/cocoa/NetsurfApp.m +++ b/cocoa/NetsurfApp.m @@ -201,8 +201,6 @@ int main( int argc, char **argv ) [app run]; netsurf_exit(); - - apple_image_fini(); return 0; } diff --git a/cocoa/apple_image.h b/cocoa/apple_image.h index 5d329c1c5..08748039f 100644 --- a/cocoa/apple_image.h +++ b/cocoa/apple_image.h @@ -26,12 +26,10 @@ #ifdef WITH_APPLE_IMAGE nserror apple_image_init(void); -void apple_image_fini(void); #else #define apple_image_init() NSERROR_OK -#define apple_image_fini() ((void) 0) #endif /* WITH_APPLE_IMAGE */ diff --git a/cocoa/apple_image.m b/cocoa/apple_image.m index f38970234..dd2ed56de 100644 --- a/cocoa/apple_image.m +++ b/cocoa/apple_image.m @@ -105,10 +105,6 @@ nserror apple_image_init(void) return NSERROR_OK; } -void apple_image_fini(void) -{ -} - nserror apple_image_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, diff --git a/content/content_factory.c b/content/content_factory.c index 3f06dc432..8da73337c 100644 --- a/content/content_factory.c +++ b/content/content_factory.c @@ -56,6 +56,9 @@ void content_factory_fini(void) content_handlers = content_handlers->next; + if (victim->handler->fini != NULL) + victim->handler->fini(); + lwc_string_unref(victim->mime_type); free(victim); diff --git a/content/content_factory.h b/content/content_factory.h index 26c587575..22205dc02 100644 --- a/content/content_factory.h +++ b/content/content_factory.h @@ -31,26 +31,17 @@ nserror HNAME##_init(void) \ { \ uint32_t i; \ - nserror error; \ + nserror error = NSERROR_OK; \ \ for (i = 0; i < NOF_ELEMENTS(HTYPELIST); i++) { \ error = content_factory_register_handler( \ HTYPELIST[i], \ &HHANDLER); \ if (error != NSERROR_OK) \ - goto error; \ + break; \ } \ \ - return NSERROR_OK; \ - \ -error: \ - HNAME##_fini(); \ - \ return error; \ -} \ -/* Pointless */ \ -void HNAME##_fini(void) \ -{ \ } struct content; diff --git a/content/content_protected.h b/content/content_protected.h index d9a021f3e..633f33241 100644 --- a/content/content_protected.h +++ b/content/content_protected.h @@ -40,6 +40,8 @@ struct rect; struct redraw_context; struct content_handler { + void (*fini)(void); + nserror (*create)(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, diff --git a/css/css.c b/css/css.c index 06dba6133..1f61524f1 100644 --- a/css/css.c +++ b/css/css.c @@ -55,6 +55,7 @@ typedef struct { * imports array */ } nscss_import_ctx; +static void nscss_fini(void); static nserror nscss_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, @@ -79,6 +80,7 @@ static css_error nscss_register_import(struct content_css_data *c, const hlcache_handle *import); static const content_handler css_content_handler = { + .fini = nscss_fini, .create = nscss_create, .process_data = nscss_process_data, .data_complete = nscss_convert, @@ -95,7 +97,7 @@ static css_stylesheet *blank_import; /** * Initialise the CSS content handler */ -nserror css_init(void) +nserror nscss_init(void) { lwc_error lerror; nserror error; @@ -117,7 +119,7 @@ nserror css_init(void) /** * Clean up after the CSS content handler */ -void css_fini(void) +void nscss_fini(void) { if (css_charset != NULL) { lwc_string_unref(css_charset); diff --git a/css/css.h b/css/css.h index 28008664f..dc6053f48 100644 --- a/css/css.h +++ b/css/css.h @@ -61,8 +61,7 @@ struct nscss_import { uint64_t media; /**< Media types that sheet applies to */ }; -nserror css_init(void); -void css_fini(void); +nserror nscss_init(void); nserror nscss_create_css_data(struct content_css_data *c, const char *url, const char *charset, bool quirks, diff --git a/desktop/netsurf.c b/desktop/netsurf.c index cb63e7d6b..91f0fac9b 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -193,7 +193,7 @@ nserror netsurf_init(int *pargc, return error; /* content handler initialisation */ - error = css_init(); + error = nscss_init(); if (error != NSERROR_OK) return error; @@ -267,15 +267,10 @@ void netsurf_exit(void) mimesniff_fini(); - /* Clean up after content handlers */ - textplain_fini(); - image_fini(); - html_fini(); - css_fini(); - /* dump any remaining cache entries */ image_cache_fini(); + /* Clean up after content handlers */ content_factory_fini(); LOG(("Closing utf8")); diff --git a/image/bmp.h b/image/bmp.h index bdd8ffa5f..9c016ecdf 100644 --- a/image/bmp.h +++ b/image/bmp.h @@ -31,6 +31,5 @@ extern bmp_bitmap_callback_vt bmp_bitmap_callbacks; /** Only to be used by ICO code. */ nserror nsbmp_init(void); -void nsbmp_fini(void); #endif diff --git a/image/gif.h b/image/gif.h index ebf821a51..a75821a96 100644 --- a/image/gif.h +++ b/image/gif.h @@ -25,6 +25,5 @@ #define _NETSURF_IMAGE_GIF_H_ nserror nsgif_init(void); -void nsgif_fini(void); #endif diff --git a/image/ico.h b/image/ico.h index 3b592d7b2..21e9bdb6e 100644 --- a/image/ico.h +++ b/image/ico.h @@ -24,6 +24,5 @@ #define _NETSURF_IMAGE_ICO_H_ nserror nsico_init(void); -void nsico_fini(void); #endif diff --git a/image/image.c b/image/image.c index 099b58ac0..cf5badc4d 100644 --- a/image/image.c +++ b/image/image.c @@ -114,51 +114,3 @@ nserror image_init(void) return NSERROR_OK; } -/** - * Finalise image content handlers - */ -void image_fini(void) -{ -#ifdef WITH_BMP - nsbmp_fini(); -#endif - -#ifdef WITH_GIF - nsgif_fini(); -#endif - -#ifdef WITH_BMP - nsico_fini(); -#endif - -#ifdef WITH_JPEG - nsjpeg_fini(); -#endif - -#ifdef WITH_MNG - nsmng_fini(); - nsjpng_fini(); -#endif - -#ifdef WITH_NSSPRITE - nssprite_fini(); -#endif - -#ifdef WITH_PNG - nspng_fini(); -#endif - -#ifdef WITH_RSVG - nsrsvg_fini(); -#endif - -#ifdef WITH_NS_SVG - svg_fini(); -#endif - -#ifdef WITH_WEBP - webp_fini(); -#endif - -} - diff --git a/image/image.h b/image/image.h index 44ea148a8..7a698e54e 100644 --- a/image/image.h +++ b/image/image.h @@ -26,6 +26,5 @@ #include "utils/errors.h" nserror image_init(void); -void image_fini(void); #endif diff --git a/image/jpeg.h b/image/jpeg.h index 163f8f286..8c054732b 100644 --- a/image/jpeg.h +++ b/image/jpeg.h @@ -24,6 +24,5 @@ #define _NETSURF_IMAGE_JPEG_H_ nserror nsjpeg_init(void); -void nsjpeg_fini(void); #endif diff --git a/image/mng.h b/image/mng.h index 69c88f362..7ad779904 100644 --- a/image/mng.h +++ b/image/mng.h @@ -26,7 +26,4 @@ nserror nsmng_init(void); nserror nsjpng_init(void); -void nsmng_fini(void); -void nsjpng_fini(void); - #endif diff --git a/image/nssprite.h b/image/nssprite.h index daa31480b..38226f84e 100644 --- a/image/nssprite.h +++ b/image/nssprite.h @@ -24,6 +24,5 @@ #define _NETSURF_NS_SPRITE_H_ nserror nssprite_init(void); -void nssprite_fini(void); #endif diff --git a/image/png.h b/image/png.h index c14521ae8..3a2e3741f 100644 --- a/image/png.h +++ b/image/png.h @@ -21,6 +21,5 @@ #define _NETSURF_RISCOS_PNG_H_ nserror nspng_init(void); -void nspng_fini(void); #endif diff --git a/image/rsvg.h b/image/rsvg.h index 21e46d1b9..f38f8b0e8 100644 --- a/image/rsvg.h +++ b/image/rsvg.h @@ -24,6 +24,5 @@ #define _NETSURF_IMAGE_RSVG_H_ nserror nsrsvg_init(void); -void nsrsvg_fini(void); #endif diff --git a/image/svg.h b/image/svg.h index 149a3c85f..96b9c3879 100644 --- a/image/svg.h +++ b/image/svg.h @@ -24,6 +24,5 @@ #define _NETSURF_IMAGE_SVG_H_ nserror svg_init(void); -void svg_fini(void); #endif diff --git a/image/webp.h b/image/webp.h index cfc869fb2..0abfec8ec 100644 --- a/image/webp.h +++ b/image/webp.h @@ -24,6 +24,5 @@ #define _NETSURF_WEBP_H_ nserror webp_init(void); -void webp_fini(void); #endif diff --git a/render/html.c b/render/html.c index 5378480c5..286fc9644 100644 --- a/render/html.c +++ b/render/html.c @@ -59,6 +59,7 @@ #define ALWAYS_DUMP_FRAMESET 0 #define ALWAYS_DUMP_BOX 0 +static void html_fini(void); static nserror html_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, @@ -109,6 +110,7 @@ static void html_dump_frameset(struct content_html_frames *frame, #endif static const content_handler html_content_handler = { + .fini = html_fini, .create = html_create, .process_data = html_process_data, .data_complete = html_convert, diff --git a/render/html.h b/render/html.h index 88c8b9bfb..c3f36fda3 100644 --- a/render/html.h +++ b/render/html.h @@ -142,7 +142,6 @@ extern char *quirks_stylesheet_url; extern bool html_redraw_debug; nserror html_init(void); -void html_fini(void); void html_redraw_a_box(struct hlcache_handle *h, struct box *box); diff --git a/render/textplain.c b/render/textplain.c index 786fe21e0..3294d536a 100644 --- a/render/textplain.c +++ b/render/textplain.c @@ -94,6 +94,7 @@ static plot_font_style_t textplain_style = { static int textplain_tab_width = 256; /* try for a sensible default */ +static void textplain_fini(void); static nserror textplain_create(const content_handler *handler, lwc_string *imime_type, const http_parameter *params, llcache_handle *llcache, const char *fallback_charset, @@ -132,6 +133,7 @@ static int textplain_coord_from_offset(const char *text, size_t offset, static float textplain_line_height(void); static const content_handler textplain_content_handler = { + .fini = textplain_fini, .create = textplain_create, .process_data = textplain_process_data, .data_complete = textplain_convert, diff --git a/render/textplain.h b/render/textplain.h index 36b9a1898..b7761a20d 100644 --- a/render/textplain.h +++ b/render/textplain.h @@ -33,7 +33,6 @@ struct http_parameter; struct rect; nserror textplain_init(void); -void textplain_fini(void); /* access to lines for text selection and searching */ unsigned long textplain_line_count(struct content *c); diff --git a/riscos/content-handlers/artworks.h b/riscos/content-handlers/artworks.h index 4a339cc84..20f6168b7 100644 --- a/riscos/content-handlers/artworks.h +++ b/riscos/content-handlers/artworks.h @@ -29,12 +29,10 @@ #ifdef WITH_ARTWORKS nserror artworks_init(void); -void artworks_fini(void); #else #define artworks_init() NSERROR_OK -#define artworks_fini() ((void) 0) #endif diff --git a/riscos/content-handlers/draw.h b/riscos/content-handlers/draw.h index a0843202a..76fcbc8dc 100644 --- a/riscos/content-handlers/draw.h +++ b/riscos/content-handlers/draw.h @@ -29,12 +29,10 @@ #ifdef WITH_DRAW nserror draw_init(void); -void draw_fini(void); #else #define draw_init() NSERROR_OK -#define draw_fini() ((void) 0) #endif /* WITH_DRAW */ diff --git a/riscos/content-handlers/sprite.h b/riscos/content-handlers/sprite.h index 79e02f44b..2219e0679 100644 --- a/riscos/content-handlers/sprite.h +++ b/riscos/content-handlers/sprite.h @@ -29,12 +29,10 @@ #ifdef WITH_SPRITE nserror sprite_init(void); -void sprite_fini(void); #else #define sprite_init() NSERROR_OK -#define sprite_fini() ((void) 0) #endif diff --git a/riscos/gui.c b/riscos/gui.c index 4df459017..793be0962 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -800,10 +800,6 @@ int main(int argc, char** argv) netsurf_exit(); - sprite_fini(); - draw_fini(); - artworks_fini(); - return 0; } -- cgit v1.2.3