aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Robinson <andr345@gmail.com>2009-05-12 12:36:36 +0200
committerAndreas Robinson <andr345@gmail.com>2009-05-12 13:02:34 +0200
commit686703ef1f9f6b123ef67360a008d1ffe9bdc074 (patch)
tree52d0d11a66fb03c9f435802e78fc132df3715796
parent3cb0e5324fdf5356a4335f12e1a5afb2074976d6 (diff)
downloadmodule-init-tools-686703ef1f9f6b123ef67360a008d1ffe9bdc074.tar.gz
util: document the rationale for the string table
Signed-off-by: Andreas Robinson <andr345@gmail.com>
-rw-r--r--util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/util.c b/util.c
index 07ac2b1..3802a02 100644
--- a/util.c
+++ b/util.c
@@ -123,6 +123,11 @@ char *underscores(char *string)
* The strings themselves are not actually kept in the table.
*
* Returns reallocated and updated string table. NULL = out of memory.
+ *
+ * Implementation note: The string table is designed to be lighter-weight
+ * and faster than a more conventional linked list that stores the strings
+ * in the list elements, as it does far fewer malloc/realloc calls
+ * and avoids copying entirely.
*/
struct string_table *strtbl_add(const char *str, struct string_table *tbl)
{
@@ -147,6 +152,14 @@ struct string_table *strtbl_add(const char *str, struct string_table *tbl)
}
/*
+ * strtbl_destroy - string table destructor
+ */
+void strtbl_free(struct string_table *tbl)
+{
+ free(tbl);
+}
+
+/*
* Get the basename in a pathname.
* Unlike the standard implementation, this does not copy the string.
*/