summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-04-19 10:34:11 +0800
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-04-30 20:22:23 +0800
commit34faa2e7ca95f8f7f4a235bb5b25fd604612f140 (patch)
tree250440f42c5b6b2baeb2ba760ef09bb573a40f2e /include
parent6b489256ee1358973d536e723c77c2483e6b9f5b (diff)
downloadbarebox-34faa2e7ca95f8f7f4a235bb5b25fd604612f140.tar.gz
stringlist: use seperately allocated string
Allocate the string in string list seperately instead of embedding a zero length string into struct stringlist. Besides looking cleaner this allows us to implement a string_list_asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'include')
-rw-r--r--include/stringlist.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/stringlist.h b/include/stringlist.h
index c923542..4b3cbf3 100644
--- a/include/stringlist.h
+++ b/include/stringlist.h
@@ -5,7 +5,7 @@
struct string_list {
struct list_head list;
- char str[0];
+ char *str;
};
int string_list_add(struct string_list *sl, char *str);
@@ -22,8 +22,10 @@ static inline void string_list_free(struct string_list *sl)
{
struct string_list *entry, *safe;
- list_for_each_entry_safe(entry, safe, &sl->list, list)
+ list_for_each_entry_safe(entry, safe, &sl->list, list) {
+ free(entry->str);
free(entry);
+ }
}
#endif /* __STRING_H */