diff options
author | Akira TAGOH <akira@tagoh.org> | 2006-11-04 11:28:00 +0000 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2006-11-04 11:28:00 +0000 |
commit | 831c136b77ecf72c93e0fae2ee91676ee7dc7e42 (patch) | |
tree | 9e133d7e6707d8cb97e508c052984bb2785546d6 | |
parent | 144dc9ca2fcf5cbecb1598e3fe9ab41b611dd9e5 (diff) |
* hieroglyph/vm.c (hg_vm_finalize): change the order of fnalization.
* hieroglyph/hglog.c (hg_logv): don't use HgString to get it working
even when memory allocation error happens.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | hieroglyph/hglist.c | 4 | ||||
-rw-r--r-- | hieroglyph/hglog.c | 38 | ||||
-rw-r--r-- | hieroglyph/version.h.in | 2 | ||||
-rw-r--r-- | hieroglyph/vm.c | 9 |
5 files changed, 36 insertions, 22 deletions
@@ -1,5 +1,10 @@ 2006-11-04 Akira TAGOH <at@gclab.org> + * hieroglyph/vm.c (hg_vm_finalize): change the order of fnalization. + + * hieroglyph/hglog.c (hg_logv): don't use HgString to get it working + even when memory allocation error happens. + * hieroglyph/vm.c (hg_vm_lookup): ues logger facility. (hg_vm_lookup_with_string): likewise. (hg_vm_set_error): likewise. diff --git a/hieroglyph/hglist.c b/hieroglyph/hglist.c index 01e24ff..2bb4dfe 100644 --- a/hieroglyph/hglist.c +++ b/hieroglyph/hglist.c @@ -31,6 +31,8 @@ #include "hgallocator-bfit.h" +#define HG_LIST_POOL_SIZE 16384 + enum { HG_LIST_MASK_UNUSED = 1 << 0, HG_LIST_MASK_LAST_NODE = 1 << 1, @@ -379,7 +381,7 @@ hg_list_init(void) __hg_list_allocator = hg_allocator_new(hg_allocator_bfit_get_vtable()); __hg_list_pool = hg_mem_pool_new(__hg_list_allocator, "HgList Pool", - 128, HG_MEM_GLOBAL | HG_MEM_RESIZABLE); + HG_LIST_POOL_SIZE, HG_MEM_GLOBAL | HG_MEM_RESIZABLE); hg_mem_pool_use_garbage_collection(__hg_list_pool, FALSE); __hg_list_initialized = TRUE; } diff --git a/hieroglyph/hglog.c b/hieroglyph/hglog.c index 5cc8fbe..09782f4 100644 --- a/hieroglyph/hglog.c +++ b/hieroglyph/hglog.c @@ -69,14 +69,14 @@ _hg_log_default_handler(HgLogType log_type, header = hg_log_get_log_type_header(log_type, domain); if (!hg_file_is_initialized()) { - g_printerr("%s ***%s%s%s %s\n", + g_printerr("%s ***%s%s%s %s\n\n", header, (subtype ? " " : ""), (subtype ? subtype : ""), (subtype ? ":" : ""), message); } else { - hg_stderr_printf("%s ***%s%s%s %s\n", + hg_stderr_printf("%s ***%s%s%s %s\n\n", header, (subtype ? " " : ""), (subtype ? subtype : ""), @@ -101,6 +101,7 @@ hg_log_init(void) HG_MEM_GLOBAL); __hg_log_options_dict = hg_dict_new(__hg_log_mem_pool, 65535); + hg_mem_add_root_node(__hg_log_mem_pool, __hg_log_options_dict); __hg_log_handler = _hg_log_default_handler; __hg_log_initialized = TRUE; @@ -114,6 +115,13 @@ hg_log_finalize(void) { if (__hg_log_initialized) { __hg_log_initialized = FALSE; +#ifdef DEBUG +#ifdef DEBUG_LOG_WITHOUT_LOGGER + hg_log_info("Masking logs are disabled now."); +#else + hg_log_info("Logging facilities are disabled now."); +#endif /* DEBUG_LOG_WITHOUT_LOGGER */ +#endif /* DEBUG */ __hg_log_options_dict = NULL; hg_mem_pool_destroy(__hg_log_mem_pool); hg_allocator_destroy(__hg_log_allocator); @@ -183,32 +191,28 @@ hg_logv(HgLogType log_type, va_list va_args) { HgValueNode *node; - HgString *string = NULL; + gchar *buffer = NULL; g_return_if_fail (format != NULL); + buffer = g_strdup_vprintf(format, va_args); if (subtype == NULL) { - default_logger:; - gchar *buffer = g_strdup_vprintf(format, va_args); - /* just invoke a default handler */ __hg_log_handler(log_type, domain, subtype, buffer, __hg_log_handler_data); - g_free(buffer); - return; + goto finalize; } if (!__hg_log_initialized) { -#ifdef DEBUG - goto default_logger; +#if defined(DEBUG) && defined(DEBUG_LOG_WITHOUT_LOGGER) + /* just invoke a default handler */ + __hg_log_handler(log_type, domain, subtype, buffer, __hg_log_handler_data); + goto finalize; #endif /* DEBUG */ } else if ((node = hg_dict_lookup_with_string(__hg_log_options_dict, subtype)) != NULL) { - string = hg_string_new(__hg_log_mem_pool, -1); - hg_string_append_vprintf(string, format, va_args); - if (HG_IS_VALUE_BOOLEAN (node)) { if (HG_VALUE_GET_BOOLEAN (node)) { /* just invoke a default handler */ - __hg_log_handler(log_type, domain, subtype, hg_string_get_string(string), __hg_log_handler_data); + __hg_log_handler(log_type, domain, subtype, buffer, __hg_log_handler_data); } } else if (HG_IS_VALUE_OPERATOR (node) || (HG_IS_VALUE_ARRAY (node) && hg_object_is_executable((HgObject *)node))) { @@ -216,8 +220,8 @@ hg_logv(HgLogType log_type, } else { hg_log_warning("Invalid object specified for logger."); } - - if (string) - hg_mem_free(string); } + finalize:; + if (buffer) + g_free(buffer); } diff --git a/hieroglyph/version.h.in b/hieroglyph/version.h.in index 5dd8f47..b3caa83 100644 --- a/hieroglyph/version.h.in +++ b/hieroglyph/version.h.in @@ -29,7 +29,7 @@ G_BEGIN_DECLS #define HIEROGLYPH_VERSION "@VERSION@" -#define HIEROGLYPH_UUID "17bc12b8-af9f-4216-bf93-2c83e487c600" +#define HIEROGLYPH_UUID "69f65847-4e4c-4073-a94a-8bd15280477b" const char *__hg_rcsid G_GNUC_UNUSED = "$Rev$"; diff --git a/hieroglyph/vm.c b/hieroglyph/vm.c index fe9257b..ec1bd03 100644 --- a/hieroglyph/vm.c +++ b/hieroglyph/vm.c @@ -378,8 +378,8 @@ hg_vm_init(void) hg_mem_init(); hg_value_node_init(); hg_file_init(); - hg_log_init(); hg_list_init(); + hg_log_init(); __hg_vm_allocator = hg_allocator_new(hg_allocator_bfit_get_vtable()); /* XXX: Ordinarily this pool should be a global pool according @@ -406,10 +406,13 @@ hg_vm_finalize(void) hg_mem_pool_destroy(__hg_vm_mem_pool); hg_allocator_destroy(__hg_vm_allocator); - hg_list_finalize(); hg_file_finalize(); - hg_value_node_finalize(); hg_log_finalize(); + /* it may be better to be finalized after logger, + * because it uses HgDict, which is referring to HgList. + */ + hg_list_finalize(); + hg_value_node_finalize(); hg_mem_finalize(); __hg_vm_is_initialized = FALSE; |