1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-15 23:35:34 +00:00

[libdom] Free keyboard and dom related strings

This commit is contained in:
Witold Filipczyk 2024-05-12 18:52:27 +02:00
parent 8a2e85b73f
commit 5c92b4ee96
5 changed files with 27 additions and 15 deletions

View File

@ -274,8 +274,8 @@ static enum {
static lwc_string *keyb_lwc[KEYB_COUNT]; static lwc_string *keyb_lwc[KEYB_COUNT];
static void void
initialize_keyb(void) keybstrings_init(void)
{ {
int i; int i;
@ -284,13 +284,12 @@ initialize_keyb(void)
if (err != lwc_error_ok) { if (err != lwc_error_ok) {
return; return;
//return _dom_exception_from_lwc_error(err);
} }
} }
} }
static void void
finalize_keyb(void) keybstrings_fini(void)
{ {
int i; int i;
@ -304,12 +303,6 @@ finalize_keyb(void)
unicode_val_T unicode_val_T
convert_dom_string_to_keycode(dom_string *dom_key) convert_dom_string_to_keycode(dom_string *dom_key)
{ {
static int initialized = 0;
if (!initialized) {
initialize_keyb();
initialized = 1;
}
if (!dom_key) { if (!dom_key) {
return 0; return 0;
} }

View File

@ -18,6 +18,8 @@ void *el_match_selector(const char *selector, void *node);
void add_lowercase_to_string(struct string *buf, const char *str, int len); void add_lowercase_to_string(struct string *buf, const char *str, int len);
bool convert_key_to_dom_string(term_event_key_T key, dom_string **res); bool convert_key_to_dom_string(term_event_key_T key, dom_string **res);
unicode_val_T convert_dom_string_to_keycode(dom_string *dom_key); unicode_val_T convert_dom_string_to_keycode(dom_string *dom_key);
void keybstrings_init(void);
void keybstrings_fini(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -24,6 +24,7 @@
#include "util/hash.h" #include "util/hash.h"
#include "util/string.h" #include "util/string.h"
static int libdom_initialised = 0;
static int in_script = 0; static int in_script = 0;
static bool static bool
@ -264,11 +265,10 @@ walk_tree(void *mapa, void *mapa_rev, struct string *buf, dom_node *node, bool s
void void
render_xhtml_document(struct cache_entry *cached, struct document *document, struct string *buffer) render_xhtml_document(struct cache_entry *cached, struct document *document, struct string *buffer)
{ {
static int initialised = 0; if (!libdom_initialised) {
if (!initialised) {
corestrings_init(); corestrings_init();
initialised = 1; keybstrings_init();
libdom_initialised = 1;
} }
if (!document->dom) { if (!document->dom) {
@ -298,6 +298,15 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str
dump_xhtml(cached, document, 0); dump_xhtml(cached, document, 0);
} }
void
free_libdom(void)
{
if (libdom_initialised) {
keybstrings_fini();
corestrings_fini();
}
}
#if 0 #if 0
static void static void
walk_tree2(struct document *document, dom_node *node) walk_tree2(struct document *document, dom_node *node)

View File

@ -19,6 +19,8 @@ struct node_rect {
void render_xhtml_document(struct cache_entry *cached, struct document *document, struct string *buffer); void render_xhtml_document(struct cache_entry *cached, struct document *document, struct string *buffer);
void dump_xhtml(struct cache_entry *cached, struct document *document, int parse); void dump_xhtml(struct cache_entry *cached, struct document *document, int parse);
void free_libdom(void);
#if 0 #if 0
void walk2(struct document *document); void walk2(struct document *document);
void scan_document(struct document_view *doc_view); void scan_document(struct document_view *doc_view);

View File

@ -29,6 +29,9 @@
#include "config/options.h" #include "config/options.h"
#include "dialogs/menu.h" #include "dialogs/menu.h"
#include "document/document.h" #include "document/document.h"
#ifdef CONFIG_LIBDOM
#include "document/libdom/renderer2.h"
#endif
#include "intl/charsets.h" #include "intl/charsets.h"
#include "intl/libintl.h" #include "intl/libintl.h"
#include "main/event.h" #include "main/event.h"
@ -327,6 +330,9 @@ terminate_all_subsystems(void)
terminate_osdep(); terminate_osdep();
#ifdef CONFIG_COMBINE #ifdef CONFIG_COMBINE
free_combined(); free_combined();
#endif
#ifdef CONFIG_LIBDOM
free_libdom();
#endif #endif
clean_temporary_files(); clean_temporary_files();
} }