summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2009-02-14 17:59:28 (GMT)
committer Daniel Silverstone <dsilvers@netsurf-browser.org>2009-02-14 17:59:28 (GMT)
commit44615333f141f8944c7570bac22def95bdcb40bb (patch)
tree6e39bc7a9559a0fd0079167383b1212a76cd4226
parentdf34246db5414c223618bb2107e94565ff444a84 (diff)
downloadlibwapcaplet-44615333f141f8944c7570bac22def95bdcb40bb.tar.gz
libwapcaplet-44615333f141f8944c7570bac22def95bdcb40bb.tar.bz2
More tests
svn path=/trunk/libwapcaplet/; revision=6507
-rw-r--r--Makefile2
-rw-r--r--src/libwapcaplet.c7
-rw-r--r--test/testmain.c1
-rw-r--r--test/tests.h1
4 files changed, 8 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index d5db551..81a0bbf 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ LIB := libwapcaplet.a
SRCS := libwapcaplet.c
HDRS := libwapcaplet/libwapcaplet.h
-TESTSRCS := testmain.c basictests.c
+TESTSRCS := testmain.c basictests.c memorytests.c
TARGET ?= debug
diff --git a/src/libwapcaplet.c b/src/libwapcaplet.c
index 7b9817a..9f408ed 100644
--- a/src/libwapcaplet.c
+++ b/src/libwapcaplet.c
@@ -213,7 +213,10 @@ lwc_context_string_unref(lwc_context *ctx, lwc_string *str)
assert(ctx);
assert(str);
- if (--(str->refcnt))
+ if (--(str->refcnt) > 1)
+ return;
+
+ if ((str->refcnt == 1) && (str->insensitive != str))
return;
*(str->prevptr) = str->next;
@@ -221,7 +224,7 @@ lwc_context_string_unref(lwc_context *ctx, lwc_string *str)
if (str->next != NULL)
str->next->prevptr = str->prevptr;
- if (str->insensitive != NULL)
+ if (str->insensitive != NULL && str->refcnt == 0)
lwc_context_string_unref(ctx, str->insensitive);
LWC_FREE(str);
diff --git a/test/testmain.c b/test/testmain.c
index c5fa0b3..29df8dc 100644
--- a/test/testmain.c
+++ b/test/testmain.c
@@ -23,6 +23,7 @@ main(int argc, char **argv)
sr = srunner_create(suite_create("Test suite for libwapcaplet"));
lwc_basic_suite(sr);
+ lwc_memory_suite(sr);
srunner_set_fork_status(sr, CK_FORK);
srunner_run_all(sr, CK_ENV);
diff --git a/test/tests.h b/test/tests.h
index e223ff1..6e842e1 100644
--- a/test/tests.h
+++ b/test/tests.h
@@ -16,5 +16,6 @@
#include "libwapcaplet/libwapcaplet.h"
extern void lwc_basic_suite(SRunner *);
+extern void lwc_memory_suite(SRunner *);
#endif /* lwc_tests_h_ */