Precis:

This is round 2 of the add-hash-extract-to-libwapcaplet stuff for Bo Yang.


Added files




Changed files


 include/libwapcaplet/libwapcaplet.h |   10 ++++++++++
 src/libwapcaplet.c                  |    8 ++++++++
 test/basictests.c                   |   16 ++++++++++++++++
 3 files changed, 34 insertions(+)


Index: test/basictests.c
===================================================================
--- test/basictests.c   (revision 6881)
+++ test/basictests.c   (working copy)
@@ -381,6 +381,18 @@ START_TEST (test_lwc_extract_data_ok)
 }
 END_TEST
 
+START_TEST (test_lwc_get_hash_value_aborts)
+{
+       lwc_get_hash_value(NULL);
+}
+END_TEST
+
+START_TEST (test_lwc_get_hash_value_ok)
+{
+       lwc_get_hash_value(intern_one);
+}
+END_TEST
+
 /**** And the suites are set up here ****/
 
 void
@@ -471,6 +483,10 @@ lwc_basic_suite(SRunner *sr)
         tcase_add_test(tc_basic, test_lwc_context_string_isequal_ok);
         tcase_add_test(tc_basic, test_lwc_context_string_caseless_isequal_ok);
         tcase_add_test(tc_basic, test_lwc_extract_data_ok);
+        tcase_add_test_raise_signal(tc_basic,
+                                    test_lwc_get_hash_value_aborts
+                                   SIGABRT);
+        tcase_add_test(tc_basic, test_lwc_get_hash_value_ok);
         suite_add_tcase(s, tc_basic);
         
         srunner_add_suite(sr, s);
Index: include/libwapcaplet/libwapcaplet.h
===================================================================
--- include/libwapcaplet/libwapcaplet.h (revision 6881)
+++ include/libwapcaplet/libwapcaplet.h (working copy)
@@ -126,5 +126,15 @@ extern const char *lwc_string_data(lwc_s
  */
 extern size_t lwc_string_length(lwc_string *str);
 
+/**
+ * Retrieve (or compute if unavailable) a hash value for the content of the 
string.
+ *
+ * @note This API should only be used as a convenient way to retrieve a hash
+ *       value for the string. This hash value should not be relied on to be
+ *       unique within an invocation of the program, nor should it be relied 
upon
+ *       to be stable between invocations of the program. Never use the hash
+ *       value as a way to directly identify the value of the string.
+ */
+extern uint32_t lwc_string_hash_value(lwc_string *str);
 
 #endif /* libwapcaplet_h_ */
Index: src/libwapcaplet.c
===================================================================
--- src/libwapcaplet.c  (revision 6881)
+++ src/libwapcaplet.c  (working copy)
@@ -342,3 +342,11 @@ lwc_string_length(lwc_string *str)
         
         return str->len;
 }
+
+uint32_t
+lwc_string_hash_value(lwc_string *str)
+{
+       assert(str);
+
+       return str->hash;
+}


Conflicted files




Removed files



Reply via email to