changeset 327:80826bf2827b

Added copier for stringlist module
author lost
date Sat, 13 Feb 2010 06:08:04 +0000
parents 2eb058346cad
children 591d01b343b9
files lwlib/lw_stringlist.c lwlib/lw_stringlist.h
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lwlib/lw_stringlist.c	Sat Feb 13 05:21:20 2010 +0000
+++ b/lwlib/lw_stringlist.c	Sat Feb 13 06:08:04 2010 +0000
@@ -75,3 +75,22 @@
 {
 	return S -> nstrings;
 }
+
+lw_stringlist_t lw_stringlist_copy(lw_stringlist_t S)
+{
+	lw_stringlist_t r;
+	
+	r = lw_alloc(sizeof(lw_stringlist_t));
+	r -> nstrings = S -> nstrings;
+	if (S -> nstrings)
+	{
+		int i;
+		
+		r -> strings = lw_alloc(sizeof(char *) * S -> nstrings);
+		for (i = 0; i < S -> nstrings; i++)
+		{
+			r -> strings[i] = lw_strdup(S -> strings[i]);
+		}
+	}
+	return r;
+}
--- a/lwlib/lw_stringlist.h	Sat Feb 13 05:21:20 2010 +0000
+++ b/lwlib/lw_stringlist.h	Sat Feb 13 06:08:04 2010 +0000
@@ -43,6 +43,7 @@
 extern char *lw_stringlist_current(lw_stringlist_t S);
 extern char *lw_stringlist_next(lw_stringlist_t S);
 extern int lw_stringlist_nstrings(lw_stringlist_t S);
+extern lw_stringlist_t lw_stringlist_copy(lw_stringlist_t S);
 
 #endif /* def ___lw_stringlist_c_seen___ */