diff options
author | Andreas Robinson <andr345@gmail.com> | 2009-05-12 12:36:36 +0200 |
---|---|---|
committer | Andreas Robinson <andr345@gmail.com> | 2009-05-12 13:02:34 +0200 |
commit | 686703ef1f9f6b123ef67360a008d1ffe9bdc074 (patch) | |
tree | 52d0d11a66fb03c9f435802e78fc132df3715796 | |
parent | 3cb0e5324fdf5356a4335f12e1a5afb2074976d6 (diff) | |
download | module-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.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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. */ |