[PATCH 02/16] util: document the rationale for the string table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Andreas Robinson <andr345@xxxxxxxxx>
---
 util.c |   13 +++++++++++++
 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.
  */
-- 
1.6.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux