Gitweb links:
...log
http://git.netsurf-browser.org/libnslog.git/shortlog/1940ea405b3ea49eca8e696e0f2938985c9c79ac
...commit
http://git.netsurf-browser.org/libnslog.git/commit/1940ea405b3ea49eca8e696e0f2938985c9c79ac
...tree
http://git.netsurf-browser.org/libnslog.git/tree/1940ea405b3ea49eca8e696e0f2938985c9c79ac
The branch, master has been updated
via 1940ea405b3ea49eca8e696e0f2938985c9c79ac (commit)
via e7e71a94cdf413ca27cf77729867c940db589353 (commit)
via fbebd45ac3204addce4240df475b9565f47df492 (commit)
from 00ea402050da45943b1cf1c11d7ac4e1ddbfa489 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libnslog.git/commit/?id=1940ea405b3ea49eca8e696e0f2938985c9c79ac
commit 1940ea405b3ea49eca8e696e0f2938985c9c79ac
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
Clean up some leaks in the test suite
diff --git a/test/basictests.c b/test/basictests.c
index 19e8bd2..c6dd9dd 100644
--- a/test/basictests.c
+++ b/test/basictests.c
@@ -321,6 +321,7 @@ START_TEST (test_nslog_parse_and_sprintf)
nslog_filter_unref(filt);
fail_unless(strcmp(ct, "cat:test") == 0,
"Printed parsed cat:test not right");
+ free(ct);
}
END_TEST
@@ -337,6 +338,7 @@ START_TEST (test_nslog_parse_and_sprintf_all_levels)
nslog_filter_unref(filt);
fail_unless(strcmp(ct, input) == 0,
"Printed parsed all-level not right");
+ free(ct);
}
END_TEST
@@ -353,6 +355,7 @@ START_TEST (test_nslog_parse_and_sprintf_all_kinds)
nslog_filter_unref(filt);
fail_unless(strcmp(ct, input) == 0,
"Printed parsed all-kind not right");
+ free(ct);
}
END_TEST
@@ -400,6 +403,7 @@ START_TEST (test_nslog_filter_filename)
"Captured message wasn't correct length");
fail_unless(strcmp(captured_rendered_message, "Hello") == 0,
"Mesage wasn't as expected");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -421,6 +425,7 @@ START_TEST (test_nslog_filter_full_filename)
"Captured message wasn't correct length");
fail_unless(strcmp(captured_rendered_message, "Hello") == 0,
"Mesage wasn't as expected");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -436,6 +441,7 @@ START_TEST (test_nslog_filter_out_filename)
NSLOG(test, WARN, "Hello");
fail_unless(captured_message_count == 0,
"Captured message count was wrong");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -457,6 +463,7 @@ START_TEST (test_nslog_filter_level)
"Captured message wasn't correct length");
fail_unless(strcmp(captured_rendered_message, "Hello") == 0,
"Mesage wasn't as expected");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -472,6 +479,7 @@ START_TEST (test_nslog_filter_out_level)
NSLOG(test, WARN, "Hello");
fail_unless(captured_message_count == 0,
"Captured message count was wrong");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -493,6 +501,7 @@ START_TEST (test_nslog_filter_dirname)
"Captured message wasn't correct length");
fail_unless(strcmp(captured_rendered_message, "Hello") == 0,
"Mesage wasn't as expected");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -508,6 +517,7 @@ START_TEST (test_nslog_filter_out_dirname)
NSLOG(test, WARN, "Hello");
fail_unless(captured_message_count == 0,
"Captured message count was wrong");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -529,6 +539,7 @@ START_TEST (test_nslog_filter_funcname)
"Captured message wasn't correct length");
fail_unless(strcmp(captured_rendered_message, "Hello") == 0,
"Mesage wasn't as expected");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -544,6 +555,7 @@ START_TEST (test_nslog_filter_out_funcname)
NSLOG(test, WARN, "Hello");
fail_unless(captured_message_count == 0,
"Captured message count was wrong");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -565,6 +577,7 @@ START_TEST (test_nslog_complex_filter1)
NSLOG(sub, DEBUG, "Hello");
fail_unless(captured_message_count == 2,
"Captured message count was wrong (3)");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -586,6 +599,7 @@ START_TEST (test_nslog_complex_filter2)
NSLOG(test, DEBUG, "Hello");
fail_unless(captured_message_count == 2,
"Captured message count was wrong (3)");
+ filter = nslog_filter_unref(filter);
}
END_TEST
commitdiff
http://git.netsurf-browser.org/libnslog.git/commit/?id=e7e71a94cdf413ca27cf77729867c940db589353
commit e7e71a94cdf413ca27cf77729867c940db589353
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
Add cleanup to nslog
diff --git a/include/nslog/nslog.h b/include/nslog/nslog.h
index 0288f5d..9113527 100644
--- a/include/nslog/nslog.h
+++ b/include/nslog/nslog.h
@@ -258,6 +258,24 @@ nslog_error nslog_set_render_callback(nslog_callback cb,
void *context);
nslog_error nslog_uncork(void);
/**
+ * Finalise log categories, release filter handles, etc.
+ *
+ * Since logging categories can have memory allocated to them at runtime,
+ * and the logging filters can have references held inside the library,
+ * clients which wish to be 'valgrind clean' may wish to call this to
+ * ensure that any memory allocated inside the nslog library is released.
+ *
+ * This does not remove the active log callback, so logging calls after this
+ * returns will still work (though will be unfiltered). Of course, they will
+ * cause memory to be allocated once more. This function can be called as
+ * many times as desired, it is idempotent.
+ *
+ * If the logging was corked when this was called, pending corked messages
+ * will be delivered if necessary before any filters are removed.
+ */
+void nslog_cleanup(void);
+
+/**
* Log filter handle
*
* nslog allows clients to set a complex filter which can be used to restrict
diff --git a/src/core.c b/src/core.c
index b09a002..15cb79a 100644
--- a/src/core.c
+++ b/src/core.c
@@ -164,3 +164,18 @@ nslog_error nslog_uncork()
return NSLOG_UNCORKED;
}
}
+
+void nslog_cleanup()
+{
+ nslog_category_t *cat = nslog__all_categories;
+ (void)nslog_uncork();
+ (void)nslog_filter_set_active(NULL, NULL);
+ while (cat != NULL) {
+ nslog_category_t *nextcat = cat->next;
+ free(cat->name);
+ cat->name = NULL;
+ cat->namelen = 0;
+ cat->next = NULL;
+ cat = nextcat;
+ }
+}
diff --git a/test/basictests.c b/test/basictests.c
index a331b2f..19e8bd2 100644
--- a/test/basictests.c
+++ b/test/basictests.c
@@ -61,7 +61,7 @@ with_simple_context_setup(void)
static void
with_simple_context_teardown(void)
{
- /* Nothing to do to tear down */
+ nslog_cleanup();
}
START_TEST (test_nslog_trivial_corked_message)
@@ -194,12 +194,12 @@ with_simple_filter_context_setup(void)
static void
with_simple_filter_context_teardown(void)
{
- /* Nothing to do to tear down */
fail_unless(nslog_filter_set_active(NULL, NULL) == NSLOG_NO_ERROR,
"Unable to clear active filter");
cat_test = nslog_filter_unref(cat_test);
cat_another = nslog_filter_unref(cat_another);
cat_test_sub = nslog_filter_unref(cat_test_sub);
+ nslog_cleanup();
}
START_TEST (test_nslog_simple_filter_corked_message)
@@ -377,9 +377,9 @@ with_trivial_filter_context_setup(void)
static void
with_trivial_filter_context_teardown(void)
{
- /* Nothing to do to tear down */
fail_unless(nslog_filter_set_active(NULL, NULL) == NSLOG_NO_ERROR,
"Unable to clear active filter");
+ nslog_cleanup();
}
START_TEST (test_nslog_filter_filename)
commitdiff
http://git.netsurf-browser.org/libnslog.git/commit/?id=fbebd45ac3204addce4240df475b9565f47df492
commit fbebd45ac3204addce4240df475b9565f47df492
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
Change category linking to be cleaner
diff --git a/src/core.c b/src/core.c
index 95d06c2..b09a002 100644
--- a/src/core.c
+++ b/src/core.c
@@ -52,6 +52,8 @@ const char *nslog_level_name(nslog_level level)
static void nslog__normalise_category(nslog_category_t *cat)
{
+ if (cat->name != NULL)
+ return;
if (cat->parent == NULL) {
cat->name = strdup(cat->cat_name);
cat->namelen = strlen(cat->name);
@@ -61,10 +63,10 @@ static void nslog__normalise_category(nslog_category_t *cat)
strcpy(cat->name, cat->parent->name);
strcat(cat->name, "/");
strcat(cat->name, cat->cat_name);
- cat->next = nslog__all_categories;
cat->namelen = strlen(cat->name);
- nslog__all_categories = cat;
}
+ cat->next = nslog__all_categories;
+ nslog__all_categories = cat;
}
static void nslog__log_corked(nslog_entry_context_t *ctx,
-----------------------------------------------------------------------
Summary of changes:
include/nslog/nslog.h | 18 ++++++++++++++++++
src/core.c | 21 +++++++++++++++++++--
test/basictests.c | 20 +++++++++++++++++---
3 files changed, 54 insertions(+), 5 deletions(-)
diff --git a/include/nslog/nslog.h b/include/nslog/nslog.h
index 0288f5d..9113527 100644
--- a/include/nslog/nslog.h
+++ b/include/nslog/nslog.h
@@ -258,6 +258,24 @@ nslog_error nslog_set_render_callback(nslog_callback cb,
void *context);
nslog_error nslog_uncork(void);
/**
+ * Finalise log categories, release filter handles, etc.
+ *
+ * Since logging categories can have memory allocated to them at runtime,
+ * and the logging filters can have references held inside the library,
+ * clients which wish to be 'valgrind clean' may wish to call this to
+ * ensure that any memory allocated inside the nslog library is released.
+ *
+ * This does not remove the active log callback, so logging calls after this
+ * returns will still work (though will be unfiltered). Of course, they will
+ * cause memory to be allocated once more. This function can be called as
+ * many times as desired, it is idempotent.
+ *
+ * If the logging was corked when this was called, pending corked messages
+ * will be delivered if necessary before any filters are removed.
+ */
+void nslog_cleanup(void);
+
+/**
* Log filter handle
*
* nslog allows clients to set a complex filter which can be used to restrict
diff --git a/src/core.c b/src/core.c
index 95d06c2..15cb79a 100644
--- a/src/core.c
+++ b/src/core.c
@@ -52,6 +52,8 @@ const char *nslog_level_name(nslog_level level)
static void nslog__normalise_category(nslog_category_t *cat)
{
+ if (cat->name != NULL)
+ return;
if (cat->parent == NULL) {
cat->name = strdup(cat->cat_name);
cat->namelen = strlen(cat->name);
@@ -61,10 +63,10 @@ static void nslog__normalise_category(nslog_category_t *cat)
strcpy(cat->name, cat->parent->name);
strcat(cat->name, "/");
strcat(cat->name, cat->cat_name);
- cat->next = nslog__all_categories;
cat->namelen = strlen(cat->name);
- nslog__all_categories = cat;
}
+ cat->next = nslog__all_categories;
+ nslog__all_categories = cat;
}
static void nslog__log_corked(nslog_entry_context_t *ctx,
@@ -162,3 +164,18 @@ nslog_error nslog_uncork()
return NSLOG_UNCORKED;
}
}
+
+void nslog_cleanup()
+{
+ nslog_category_t *cat = nslog__all_categories;
+ (void)nslog_uncork();
+ (void)nslog_filter_set_active(NULL, NULL);
+ while (cat != NULL) {
+ nslog_category_t *nextcat = cat->next;
+ free(cat->name);
+ cat->name = NULL;
+ cat->namelen = 0;
+ cat->next = NULL;
+ cat = nextcat;
+ }
+}
diff --git a/test/basictests.c b/test/basictests.c
index a331b2f..c6dd9dd 100644
--- a/test/basictests.c
+++ b/test/basictests.c
@@ -61,7 +61,7 @@ with_simple_context_setup(void)
static void
with_simple_context_teardown(void)
{
- /* Nothing to do to tear down */
+ nslog_cleanup();
}
START_TEST (test_nslog_trivial_corked_message)
@@ -194,12 +194,12 @@ with_simple_filter_context_setup(void)
static void
with_simple_filter_context_teardown(void)
{
- /* Nothing to do to tear down */
fail_unless(nslog_filter_set_active(NULL, NULL) == NSLOG_NO_ERROR,
"Unable to clear active filter");
cat_test = nslog_filter_unref(cat_test);
cat_another = nslog_filter_unref(cat_another);
cat_test_sub = nslog_filter_unref(cat_test_sub);
+ nslog_cleanup();
}
START_TEST (test_nslog_simple_filter_corked_message)
@@ -321,6 +321,7 @@ START_TEST (test_nslog_parse_and_sprintf)
nslog_filter_unref(filt);
fail_unless(strcmp(ct, "cat:test") == 0,
"Printed parsed cat:test not right");
+ free(ct);
}
END_TEST
@@ -337,6 +338,7 @@ START_TEST (test_nslog_parse_and_sprintf_all_levels)
nslog_filter_unref(filt);
fail_unless(strcmp(ct, input) == 0,
"Printed parsed all-level not right");
+ free(ct);
}
END_TEST
@@ -353,6 +355,7 @@ START_TEST (test_nslog_parse_and_sprintf_all_kinds)
nslog_filter_unref(filt);
fail_unless(strcmp(ct, input) == 0,
"Printed parsed all-kind not right");
+ free(ct);
}
END_TEST
@@ -377,9 +380,9 @@ with_trivial_filter_context_setup(void)
static void
with_trivial_filter_context_teardown(void)
{
- /* Nothing to do to tear down */
fail_unless(nslog_filter_set_active(NULL, NULL) == NSLOG_NO_ERROR,
"Unable to clear active filter");
+ nslog_cleanup();
}
START_TEST (test_nslog_filter_filename)
@@ -400,6 +403,7 @@ START_TEST (test_nslog_filter_filename)
"Captured message wasn't correct length");
fail_unless(strcmp(captured_rendered_message, "Hello") == 0,
"Mesage wasn't as expected");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -421,6 +425,7 @@ START_TEST (test_nslog_filter_full_filename)
"Captured message wasn't correct length");
fail_unless(strcmp(captured_rendered_message, "Hello") == 0,
"Mesage wasn't as expected");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -436,6 +441,7 @@ START_TEST (test_nslog_filter_out_filename)
NSLOG(test, WARN, "Hello");
fail_unless(captured_message_count == 0,
"Captured message count was wrong");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -457,6 +463,7 @@ START_TEST (test_nslog_filter_level)
"Captured message wasn't correct length");
fail_unless(strcmp(captured_rendered_message, "Hello") == 0,
"Mesage wasn't as expected");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -472,6 +479,7 @@ START_TEST (test_nslog_filter_out_level)
NSLOG(test, WARN, "Hello");
fail_unless(captured_message_count == 0,
"Captured message count was wrong");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -493,6 +501,7 @@ START_TEST (test_nslog_filter_dirname)
"Captured message wasn't correct length");
fail_unless(strcmp(captured_rendered_message, "Hello") == 0,
"Mesage wasn't as expected");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -508,6 +517,7 @@ START_TEST (test_nslog_filter_out_dirname)
NSLOG(test, WARN, "Hello");
fail_unless(captured_message_count == 0,
"Captured message count was wrong");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -529,6 +539,7 @@ START_TEST (test_nslog_filter_funcname)
"Captured message wasn't correct length");
fail_unless(strcmp(captured_rendered_message, "Hello") == 0,
"Mesage wasn't as expected");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -544,6 +555,7 @@ START_TEST (test_nslog_filter_out_funcname)
NSLOG(test, WARN, "Hello");
fail_unless(captured_message_count == 0,
"Captured message count was wrong");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -565,6 +577,7 @@ START_TEST (test_nslog_complex_filter1)
NSLOG(sub, DEBUG, "Hello");
fail_unless(captured_message_count == 2,
"Captured message count was wrong (3)");
+ filter = nslog_filter_unref(filter);
}
END_TEST
@@ -586,6 +599,7 @@ START_TEST (test_nslog_complex_filter2)
NSLOG(test, DEBUG, "Hello");
fail_unless(captured_message_count == 2,
"Captured message count was wrong (3)");
+ filter = nslog_filter_unref(filter);
}
END_TEST
--
NetSurf Parametric Logging Library
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org